Tensor Network (TN) kernel machines accelerate supervised learning by using low-rank TNs to reduce computation and memory. However, most TN-based methods are deterministic with manually tuned ranks and feature dimensions, while the existing Bayesian TN kernel machine is restricted to the CANDECOMP/PARAFAC decomposition (CPD), whose single rank is shared by all modes. We extend this framework to the tensor train (TT) and propose Bayesian Tensor Train Kernel Machines (BTT-KM), whose hierarchical ARD-type priors on the TT cores infer the TT ranks and feature dimensions from data. Since each TT core is coupled to the others only through its neighbors, its closed-form posterior update requires propagating the contributions of all other cores along the chain. Mean-field variational inference yields a Bayesian alternating least squares algorithm with the same computational complexity as its deterministic counterpart and a closed-form predictive distribution. A synthetic experiment illustrates that BTT-KM recovers the true TT ranks and feature dimensions from an over-parameterized initialization.
Tensor Network (TN) kernel machines are a class of kernel methods designed for high-dimensional feature spaces and large-scale datasets. By learning directly in feature space and imposing a low-rank tensor structure on the model weights, they avoid the memory and computational cost of standard kernel methods. For a set of data samples {xn,yn}∣xn∈RD,yn∈R}n=1N, TN kernel machines consider the model
yn=φ(xn)⊤w+en,(1)
where w denotes the model weight vector and en represents measurement noise. The feature map φ(⋅):RD→RM1M2⋯MD is constrained to a Kronecker-product structure
where each factor φ(d)∈RMd is a feature vector for dimension d. This feature map induces the finite-dimensional kernel kM(xn,xm)=⟨φ(xn),φ(xm)⟩, which, depending on the
choice of basis functions, can represent the target kernel exactly, as for polynomial features (Batselier et al., 2017; Novikov et al., 2018), or approximate it, as for Gaussian kernels (Wesel and Batselier, 2021, 2024). Model (1) is therefore a primal formulation of kernel machines (Suykens et al., 2002; Wesel and Batselier, 2021, 2025): w is learned directly in feature space, avoiding the O(N2) memory and O(N3) cost of the dual formulation.
By exploiting the Kronecker-product structure of (2), TN kernel machines further impose a low-rank TN structure on w, so that it is never formed explicitly but represented and learned directly through its tensor components. Two common choices are the CANDECOMP/PARAFAC decomposition (CPD) (Harshman, 1970; Carroll and Chang, 1970) and the tensor train (TT) decomposition (Oseledets, 2011). Assuming M1=⋯=MD=M, so that w∈RMD, both reduce the storage of w from O(MD) to O(DMR) for CPD and O(DMR2) for TT, which is linear in D. Both can also be trained with the alternating least squares (ALS) algorithm, at a cost of O(ND(MR)2+D(MR)3) for CPD and O(ND(MR2)2+D(MR2)3) for TT, which is linear in N and D. This makes both decompositions suitable for representing w in high-dimensional, large-scale settings, while the low-rank structure also acts as an implicit regularizer by limiting the degrees of freedom of the model. The two decompositions differ in how their components interact. In CPD, all D factor matrices share a single rank R. In TT, each core shares a rank only with its neighbors, so the model has D−1 ranks R2,…,RD, one between each pair of consecutive cores. As a result, the model capacity in TT can differ across the ranks, so that strongly interacting modes can be given a higher rank than weakly interacting ones, instead of using one global rank for all modes.
In (Kilic and Batselier, 2025), we introduced Bayesian Tensor Network kernel machines (BTN-KM), a fully probabilistic treatment of CPD-based kernel machines. Hierarchical ARD-type priors on the factor matrices infer the tensor rank and the feature dimensions from data, and mean-field variational inference yields a Bayesian ALS algorithm with the same computational complexity as its deterministic counterpart. In this paper, we extend this framework to the TT format and propose Bayesian Tensor Train Kernel Machines (BTT-KM). This extension is not a direct translation of the CPD case. Since each TT core is coupled to the rest of the network only through its neighboring cores, deriving its closed-form posterior update requires propagating the contributions of all other cores along the chain.
We adapt the hierarchical prior to the TT structure through two sets of precision parameters. The rank precisions λd are shared by two consecutive cores and penalize the components of the TT rank Rd, while the feature precisions δd are specific to each core and penalize the components of its feature dimension Md. We derive the resulting mean-field variational posterior of all parameters and hyperparameters, show that it again leads to a Bayesian ALS algorithm with the same computational complexity as deterministic TT-ALS, and derive the corresponding closed-form predictive distribution. The resulting method automatically infers the TT ranks {Rd}d=2D and feature dimensions {Md}d=1D of TT kernel machines directly from data. A synthetic experiment illustrates how the penalization acts on the TT cores and recovers the true ranks and feature dimensions.
The remainder of the paper is organized as follows. Section 2 introduces the notation and TT preliminaries. Section 3 presents BTT-KM: the model and priors (Section 3.1), the variational updates and lower bound (Section 3.2), the predictive distribution (Section 3.3), and implementation details and complexity (Section 3.4). Section 4 illustrates the penalization on synthetic data, and Section 5 concludes. Proofs are in the Appendix, and code is available at https://github.com/afrakilic/BTKM.
2 Preliminaries and notation
The order (also called the number of modes) of a tensor is the number of its dimensions. Scalars are denoted by lowercase letters (e.g., a), vectors (first-order tensors) by bold lowercase letters (e.g., a), matrices (second-order tensors) by bold uppercase letters (e.g., A), and higher-order tensors (of order D≥3) by bold calligraphic symbols (e.g., A). For a Dth-order tensor A∈RI1×⋯×ID, the entry indexed by (i1,…,iD) is denoted by ai1⋯iD, where id=1,…,Id for d=1,…,D.
The vectorization of a tensor is denoted by the operator vec(⋅) and defined as vec(A)=a∈RI1I2⋯ID, where the entries of A are stacked into a vector according to a fixed ordering convention. The reshape operator R{⋅}I1,I2,…,ID maps a tensor to the prescribed dimensions I1,I2,…,ID, preserving the total number of entries and incorporating any index permutations required by the adopted ordering convention. The operator diag(⋅) returns a diagonal matrix when applied to a vector and extracts the main diagonal as a vector when applied to a matrix. The Kronecker product of two matrices A∈RI×J and B∈RK×L is denoted by A⊗B∈RKI×LJ. The Khatri-Rao product A⊙B of the matrices A∈RI×J and B∈RK×J is an IK×J matrix obtained by taking the column-wise Kronecker product. The identity matrix is conventionally denoted by I, with its dimensions either inferred from the context or explicitly stated as a subscript.
Definition 1 (Tensor Train Decomposition) Tensor Train decomposition represents w∈RMD using D third-order tensors W(d)∈RRd×Md×Rd+1 such that
The auxiliary dimensions R1,R2,…,RD+1 are called TT ranks. To ensure that the right-hand side of (3) is a scalar, the boundary condition R1=RD+1=1 is required. TT decomposition is non-unique, with a storage complexity of O(R2MD) due to the D tensors W(d).
Definition 2 (Slices of a TT core) Let W(d)∈RRd×Md×Rd+1 be the dth TT core in a Tensor Train decomposition. A slice of W(d) is a two-dimensional subtensor (i.e., matrix) obtained by fixing one index. The horizontal, lateral, and frontal slices are denoted by Wrd::(d), W:md:(d), and W::rd+1(d), respectively, as shown in Figure 1.
Definition 3 (mode-n unfolding of a TT core) Let W(d)∈RRd×Md×Rd+1 be a third-order TT core. The mode-n unfolding rearranges the entries of W(d) into a matrix by stacking all slices obtained by fixing the nth index, while preserving a fixed ordering of the remaining indices. The resulting matrix is denoted by
W(n)(d)∈RIn×∏m=nIm,n∈{1,2,3},
where (I1,I2,I3):=(Rd,Md,Rd+1).
(a) Horizontal: Wrd::(d)∈RMd×Rd+1
(b) Lateral: W:md(d)∈RRd×Rd+1
(c) Frontal: W:rd+1(d)∈RRd×Md
Figure 1: Horizontal Wrd::(d), lateral W:md(d), and frontal W:rd+1(d) slices of a TT core W(d).
3 Probabilistic Tensor Train Kernel Machines
3.1 Probabilistic model and priors
When N inputs {xn}n=1N and outputs {yn}n=1N are available for learning then model (1) can be expressed as a linear matrix equation
y=Φ⊤w+e(4)
where y∈RN and e∈RN, with e∼N(0,τ−1IN). The matrix Φ∈RMD×N is constructed such that its nth column contains φ(xn). Due to the tensor-product structure of the feature map in (2), Φ can be expressed as a column-wise Khatri-Rao product of component matrices Φ=Φ(1)⊙Φ(2)⊙…⊙Φ(D), where the columns of Φ(d)∈RMd×N are the feature vectors φ(d)(xn(d)), for all n∈[1,N]. Consequently, assuming a TT decomposed weight vector w along with the Gaussian noise model, the likelihood of the observed outputs is given by
p(y∣{W(d)}d=1D,τ)=n=1∏NN(yn∣φ(xn)⊤w,τ−1),(5)
where the parameter τ denotes the noise precision. Each TT core W(d)∈RRd×Md×Rd+1 can be considered through its two-dimensional slices obtained by fixing one index, namely the horizontal, lateral, or frontal slices, as illustrated in Figure 1. The TT ranks {Rd}d=2D and feature dimensions {Md}d=1D control the model complexity, but selecting them a priori is difficult and computationally expensive.
We therefore adopt a Bayesian model selection approach that infers the effective values of {Rd}d=2D and {Md}d=1D directly from the data. To this end, we place an ARD-type hierarchical prior on the TT cores {W(d)}d=1D, with continuous hyperparameters governing the variances of their horizontal, lateral, and frontal slices. This prior shrinks irrelevant slices toward zero, yielding simpler TT representations and allowing automatic inference of model complexity during training. This approach is motivated by automatic relevance determination (ARD) (Neal, 1996; MacKay, 1994) and is related to Bayesian CP tensor completion methods that infer the CP rank using similar priors (Zhao et al., 2015).
More specifically, we introduce two sets of relevance parameters. The first set, λd:=[λ1d,λ2d,…,λRd] for d=2,…,D, is associated with the TT rank dimensions. Since a Tensor Train of order D has D−1 rank dimensions, these parameters are defined only for d=2,…,D and are shared between two consecutive TT cores. Each parameter λrd controls the regularization strength of the rdth horizontal slice of W(d) and, at the same time, the rdth frontal slice of the preceding core W(d−1). In this way, λd couples adjacent TT cores through their common rank dimension. The second set of relevance parameters, δd:=[δ1d,δ2d,…,δMd] for d=1,…,D, is specific to the dth TT core. Each parameter δmd controls the regularization strength of the mdth lateral slice of W(d) and therefore acts only within that core.
The prior distribution of the vectorized TT cores is a zero-mean Gaussian prior
where Λd+1⊗Δd⊗Λd=diag(λd+1)⊗diag(δd)⊗diag(λd) represents the inverse covariance matrix. To allow TT ranks and feature dimensions to be inferred from data, we place Gamma priors over relevance parameters {λd}d=2D, {δd}d=1D. The hyperprior over λd is factorized across the rank components
p(λd)=rd=1∏RdGa(λrd∣c0rd,e0rd),(6)
while the hyperprior over δd is factorized over their individual feature dimensions
p(δd)=md=1∏MdGa(δmd∣g0md,h0md),(7)
where Ga(x∣a,b)=baxa−1e−bx/Γ(a) denotes a Gamma distribution and Γ(a) is the Gamma function. To complete our model with a fully Bayesian treatment, we also place a hyperprior over the noise precision τ, that is,
p(τ)=Ga(τ∣a0,b0).(8)
Denoting all latent variables and hyperparameters by Θ={{W(d)}d=1D,{δd}d=1D,{λd}d=2D,τ}, the joint distribution p(y,Θ) can be expressed as
Figure 2 shows the probabilistic graphical model representing the joint distribution for the case where w is decomposed using the Tensor Train (TT) format. For simplicity, the deterministic design matrices {Φ(d)}d=1D are not shown. The TT cores {W(d)}d=1D, and the shape and rate hyperparameters of the Gamma distributions, represented by unbounded nodes in the figure, must be initialized before identification.
Figure 2: Representation of BTT-KM with the TT-decomposed weight vector w as a probabilistic graphical model showing the ARD-type hierarchical priors over the TT cores {W(d)}d=1D by the relevance parameters {λd}d=2D and {δd}d=1D. The dashed node denotes the observed data y, while the solid nodes represent random variables. Shape and rate hyperparameters of the Gamma priors placed on {λd}d=2D, {δd}d=1D and τ are shown as unbounded nodes.
3.2 Model Learning
The full posterior distribution of all variables in Θ given the observed data is
p(Θ∣y)=∫p(y,Θ)dΘp(y,Θ).(10)
Based on the posterior distribution of Θ, the predictive distribution of an unseen output yi can be inferred by
p(yi∣y)=∫p(yi∣Θ)p(Θ∣y)dΘ.(11)
An exact Bayesian inference of (10) and (11) requires integrating over all latent variables and hyperparameters, making it analytically intractable. Therefore, as presented in (Kilic and Batselier, 2025) we perform a Bayesian identification using mean-field variational inference (Winn and Bishop, 2005). The key idea is to approximate the true posterior p(Θ∣y) with a variational distribution q(Θ) by minimizing the Kullback–Leibler (KL) divergence. This is equivalent to maximizing a lower bound L(q) on the log model evidence lnp(y), defined as L(q)=Eq(Θ)[lnp(y,Θ)]+H(q(Θ)), where H(q(Θ)) denotes the entropy of the variational distribution. The maximum of the lower bound occurs when the KL divergence vanishes, implying q(Θ)=p(Θ∣y). The mean-field assumption factorizes the variational distribution over each variable θj∈Θ as
In other words, this factorization assumes that all variables θj∈Θ are independent. The functional form of each factor can then be derived analytically in turn. Specifically, the optimal qj(θj) is obtained by maximizing L(q), with the maximum occurring when
lnqj(θj)=Eq(Θ\θj)[lnp(y,Θ)]+const,(13)
where Eq(Θ\θj)[⋅] denotes the expectation taken with respect to the variational distributions of all variables except θj. Since all distributions in the model belong to the exponential family and each prior is conjugate to the corresponding likelihood term when all other variables are held fixed, (13) yields closed-form posterior updates for each factor. Identification proceeds by initializing each qj(θj) and iteratively updating them using the update rules until convergence. In the following, we present the posterior update rules for each qj(θj), for all θj∈Θ.
3.2.1 POSTERIOR DISTRIBUTION OF THE TT CORES
To derive the update rule for the dth TT core W(d), we rewrite the model to isolate its dependence on this core.
Theorem 4 Let w be represented in TT format by the cores {W(k)}k=1D. For any fixed d∈[1,D], the model output is linear in the dth core,
Φ⊤w=G\d⊤vec(W(d)),(14)
where
G\d=G>d⊙Φ(d)⊙G<d∈RRdMdRd+1×N.(15)
and vec(W(d))∈RRdMdRd+1 is the column-wise vectorization of the dth TT core. The matrix G\d can be interpreted as the design matrix corresponding to vec(W(d)).
Proof See Section 1 of the Appendix.
The matrices G<d and G>d in Theorem 4 collect the contributions of all modes preceding and following the dth mode, respectively. Specifically, G<d aggregates information from modes 1 through d−1, while G>d aggregates information from modes d+1 through D. Using the mode-3 and mode-1 unfoldings of the TT cores W(k)∈RRk×Mk×Rk+1, denoted by W(3)(k) and W(1)(k), respectively, we introduce forward and backward accumulators that allow efficient sequential contraction of all TT cores except the dth one.
Definition 5 (Forward and backward accumulators) Given the boundary condition R1=RD+1=1, the forward and backward accumulators are defined recursively by
See Section 3 of the Appendix for a detailed derivation of (18). The matrix Eq[G\dG\d⊤] represents the expected Gram matrix of the model fitting term Φ⊤w in (14), excluding the dth core W(d). Equivalently, it corresponds to the expected second moment of the design matrix G\d, which combines the features Φ(d) with all TT cores W(k) for k=d. This term cannot be computed straightforwardly, and therefore, we first need to introduce the following results. In order to express Eq[G\dG\d⊤] in terms of the posterior parameters of the TT cores in (18), we reformulate it by isolating the random variables in the expression as in the following theorem.
Theorem 6 For any fixed d∈{1,…,D}, and assuming that the TT cores W(k) are mutually independent under q for all k=d, the expected Gram matrix factorizes into left and right contributions as
The matrices Eq[G<d⊙G<d] and Eq[G>d⊙G>d] represent second-order summaries of the partial contractions to the left and right of core d, respectively. To evaluate these matrices efficiently, we use the mode-3 and mode-1 unfoldings of the TT cores and introduce the forward and backward Gram matrices.
Definition 7 (Forward and backward Gram matrices) We define the forward and backward Gram matrices as H<k:=Eq[G<k⊙G<k] and H>k:=Eq[G>k⊙G>k], respectively, where H<k∈RRk2×N and H>k∈RRk+12×N. These matrices summarize the contributions of all TT cores located to the left and right of the kth core.
Under the boundary conditions R1=RD+1=1 and assuming that the TT cores W(k) are mutually independent, we initialize the recursions with H<1:=1N⊤ and H>D:=1N⊤. The forward and backward Gram matrices then satisfy the following recursive relations:
where P denotes the fixed permutation matrix that reorders the Kronecker factors according to the adopted index ordering. A derivation of the recursive relations in (20) is provided in Section 5 of the Appendix. The expectation terms are evaluated as
The identities in (21) follow directly from the standard second-moment relation E[x2]=E[x]2+Var[x], where the covariance terms account for the posterior uncertainty of the TT cores required in the forward and backward Gram matrix recursions. When these covariance terms vanish, the other TT cores are treated as deterministic, and the posterior mean update reduces to a regularized ALS update for the dth TT core W(d).
To evaluate these covariance terms in terms of the posterior parameters obtained from (18), we use the following lemma.
Lemma 8 Let W(k)∈RA×B and let vec(W(k))∈RAB denote its column-wise vectorization. Then,
W(k)⊗W(k)=R{vec(W(k))vec(W(k))⊤}A2×B2.(22)
That is, the Kronecker product W(k)⊗W(k) can be obtained by reshaping the outer product of the vectorized matrix into a matrix of size A2×B2.
The intuitive interpretation of Lemma 8 is that the Kronecker product of W(k) with itself is the same as the outer product of vec(W(k)) with itself, but reshaped into a structured block form. Using this identity, the covariance term in (21) can be computed by reshaping the posterior covariance matrices of the corresponding TT cores as
As illustrated in Figure 2, inference over λd is performed by gathering information from two cores that are W(d−1) and W(d) together with its hyperprior. Using (13), the posterior distributions of λrd, for all rd∈[1,Rd], are obtained as independent Gamma distribution,
qλd(λd)=rd=1∏RdGa(λrd∣cNrd,eNrd),(24)
where cNrd,eNrd are the posterior parameters learned from N training points and updated by
Section 7 of the Appendix provides a detailed derivation of (25). The two expectations appearing in the update of eNd are evaluated in closed form using the posterior mean and covariance of the TT cores given in (18). For an efficient evaluation of these expectations, it is convenient to explicitly collect the posterior variances of the TT-core entries. The diagonal of the covariance matrix Σ(d) contains the marginal variances of the entries of the
d-th TT core, ordered consistently with vec(W(d)). We therefore define a variance tensor V(d)∈RRd×Md×Rd+1 by reshaping this vector as
V(d):=R{diag(Σ(d))}Rd×Md×Rd+1.
The diagonal of the first expected inner product, Eq[W(3)(d−1)(Δd−1⊗Λd−1)W(3)(d−1)⊤], is computed as
Equations (26) and (27) are then substituted into (25) to obtain the update of eNd. The posterior expectation can be obtained by Eq[λd]=[cN1d/eN1d,…,cNRd/eNRd]⊤, and thus Eq[Λd]=diag(Eq[λd]), for d=2,…,D. Each λrd jointly controls the rdth frontal slice W::rd(d−1) of core W(d−1) and the rdth horizontal slice Wrd::(d) of core W(d). These slices correspond to the same component of their shared rank dimension Rd. The update of λrd depends on the weighted squared entries of both slices, including their posterior variances. Smaller weighted second moments yield a smaller eNrd and hence a larger Eq[λrd], increasing shrinkage of both slices and promoting a lower effective TT rank Rd.
As shown in Figure 2, the inference of δd is performed by gathering information from the dth TT core and incorporating information from its hyperprior. By applying (13), we can identify the posteriors of δmd, ∀d∈[1,D] and ∀md∈[1,Md] as an independent Gamma distribution,
qδd(δd)=md=1∏MdGa(δmd∣gNmd,hNmd),(28)
where gNmd, hNmd are the posterior parameters learned from N training points and updated by
See Section 6 of the Appendix for a detailed derivation of (29). The expectation of the inner product of the mdth lateral slice of the dth core w.r.t q distribution can be computed using the posterior parameters of W(d) in (18) as
which is then substituted into (29) to obtain the update of hNd. The posterior expectation can be obtained by Eq[δd]=[gN1d/hN1d,…,gNMd/hNMd]⊤, and thus Eq[Δd]=diag(Eq[δd]), for
d=1,…,D. Each δmd controls the relevance of the mdth feature through the lateral slice W:md(d) of core W(d). Its update depends on the weighted squared entries of this slice, including their posterior variances. Smaller weighted second moments yield a smaller hNmd and hence a larger Eq[δmd], increasing shrinkage of the slice and suppressing the corresponding feature.
The updates of λd and δd are interdependent. Each λrd regularizes a pair of matching slices in two adjacent cores, while each δmd regularizes a lateral slice within one core. The rank-precision updates in (25) depend on the feature precisions, and the feature-precision updates in (29) depend on both adjacent rank precisions. For fixed posterior core moments, larger rank precisions increase hNmd and reduce Eq[δmd], weakening feature shrinkage. Conversely, larger feature precisions increase the corresponding eNrd and reduce Eq[λrd], weakening rank shrinkage. This compensating interaction balances regularization across rank components and feature dimensions.
3.2.3 POSTERIOR DISTRIBUTION OF NOISE PRECISION τ
The noise precision τ can be inferred by receiving information from observed data and its co-parents, including all the TT cores, and incorporating the information from its hyperprior. Applying (13), the variational posterior is a Gamma distribution, given by
qτ(τ)=Ga(τ∣aN,bN),(31)
where the posterior parameters are updated by
aNbN=a0+2N,=b0+21Eq[∥y−Φ⊤w∥F2].(32)
See Section 8 of the Appendix for a detailed derivation of (32). The posterior expectation of model residuals Eq[∥y−Φ⊤w∥F2] in Equation (32) cannot be computed straightforwardly and, therefore, we need to introduce the following results. When no core is excluded, the full model is obtained by applying the forward accumulator recursion through all D modes. Starting from G<1=1N⊤, the forward contraction propagates sequentially across the entire tensor train, yielding
To evaluate the last term, note that for a row vector G<D+1∈R1×N the Khatri–Rao product G<D+1⊙G<D+1∈R1×N contains the squared entries of G<D+1. Hence
Here H<D+1∈R1×N is the forward Gram matrix propagated through all modes without excluding any core. It follows the same recursion as (20), initialized with H<1=1N⊤ and run for k=2,…,D+1. Substituting (35) into (34) yields
bN=b0+21(∥y∥F2−2Eq[G<D+1]y+H<D+11N).(36)
Finally, the posterior expectation of the noise precision is Eq[τ]=aN/bN.
3.2.4 LOWER BOUND MODEL EVIDENCE
The mean-field variational inference framework maximizes the evidence lower bound (ELBO). For fixed ranks and feature dimensions, exact coordinate updates ensure that the ELBO is non-decreasing across iterations, allowing it to be used as a convergence criterion. The lower bound of the log marginal likelihood is defined by
L(q)=Eq(Θ)[lnp(y,Θ)]+H(q(Θ)),(37)
where the first term denotes the posterior expectation of the log-joint distribution, and the second term denotes the entropy of the variational posterior. Evaluating these terms using the Gaussian core posteriors and Gamma precision posteriors yields
where Λ~d:=diag(λ~d) and Δ~d:=diag(δ~d), with λ~d:=Eq[λd] and δ~d:=Eq[δd] the posterior means of the rank and feature precisions, respectively. See Section 9 of the Appendix for a detailed derivation of (38). The posterior expectation of the squared model residual, Eq[∥y−Φ⊤w∥F2], can be computed using (34) and (35). The lower bound can be interpreted as follows. The first term captures the model residual. The second term represents a weighted sum of the squared entries of the TT cores, incorporating their posterior uncertainty. The remaining terms correspond to the negative KL divergence between the posterior and prior distributions of the hyperparameters.
3.3 Predictive distribution
The predictive distribution over unseen data points, given the training data, can be approximated using the variational posterior distribution as
Here, Eq[g\d(xi)]=Eq[g>d(xi)]⊗φ(d)(xi(d))⊗Eq[g<d(xi)]∈RRdMdRd+1, where g<d(xi) and g>d(xi) are the forward and backward accumulators of Definition 5 evaluated at the test input xi, with their expectations obtained by replacing each core with its posterior mean. See Section 10 of the Appendix for a detailed derivation. Thus, the predictive variance can be obtained by Var(yi∣y)=νy−2νySi−1, for νy>2.
3.4 Implementation details
This section describes the practical implementation of the inference procedure in Algorithm 1. Most design choices follow the CPD case (Kilic and Batselier, 2025), so we restate them only where the TT structure changes them.
3.4.1 INITIALIZATION OF HYPERPARAMETERS
Variational Bayesian inference converges to a local optimum of the lower bound. Appropriate initialization is therefore crucial to avoid poor local solutions. As in the CPD case (Kilic and Batselier, 2025), we adopt uninformative priors by setting the hyperparameters c0d, e0d, g0d and h0d to 10−6. Accordingly, the precision matrices for penalization are initialized as Δd=I for all d∈[1,D] and Λd=I for all d∈[2,D]. Since R1=RD+1=1, the boundary precisions are scalars; they have no hyperprior, are not inferred, and are fixed at Λ1=ΛD+1=[1]. For the noise precision, we set a0=b0=10−3 in our experiments, so that τ is initialized at 1. Note, however, that each TT core is regularized by the product of three precision matrices, Λd+1⊗Δd⊗Λd, rather than two as in the CPD case, which strengthens the prior relative to the likelihood. A larger initial noise precision, for instance a0∈{10−2,10−1} with b0=10−3 so that τ starts at 10 or 102, may therefore be beneficial, as it increases the influence of the likelihood in (18) and compensates for the stronger regularization.
During the first five iterations only the cores are updated, so τ, λd and δd stay at their initial values. The cores W(d) are initialized from N(0,I), and the covariance matrices Σ(d) are set to σ2I with σ2=10−5. The ranks {Rd}d=2D and feature dimensions {Md}d=1D are chosen manually based on the available computational resources. The hyperparameter values used in our experiments are given in Section 4.
3.4.2 EFFICIENT VARIATIONAL UPDATES AND COMPUTATIONAL COMPLEXITY
The inference sweeps over the TT cores. In each iteration, we update for d=1,…,D the posterior of the core q(vec(W(d))) using (18), then q(λd) using (25) (for d≥2) and q(δd) using (29). After the sweep, we update q(τ) using (32), optionally prune redundant ranks, and evaluate the lower bound using (38).
Algorithm 1 Learning Bayesian TT Kernel Machines
Require: Inputs {xn}n=1N and outputs y={yn}n=1N
1: Initialization: choose TT ranks {Rd}d=2D and feature dimensions {Md}d=1D
6: Set λrd=c0rd/e0rd for all rd∈{1,…,Rd} and d∈{2,…,D}
7: Set δmd=g0md/h0md for all md∈{1,…,Md} and d∈{1,…,D}
8: Set iteration counter t=0
9: repeat
10: t←t+1
11: for d=1 to D do
12: Update the posterior q(vec(W(d))) using Eq. (18)
13: if t>5 then
14: if d≥2 then
15: Update the posterior q(λd) using Eq. (25)
16: end if
17: Update the posterior q(δd) using Eq. (29)
18: end if
19: end for
20: if t>5 then
21: Update the posterior q(τ) using Eq. (32)
22: if rank pruning is enabled then
23: For all d∈{2,…,D}, remove the rank components rd whose variance explained is below the threshold ϵ, i.e., the corresponding frontal slices of W(d−1) and horizontal slices of W(d)
24: end if
25: end if
26: Evaluate the lower bound using Eq. (38)
27: until convergence
28: Compute the predictive distribution using Eq. (40)
Each core update needs the expectations Eq[G\d] and Eq[G\dG\d⊤] of the contraction of all other cores. Recomputing them from scratch would add a factor D to the cost, so we propagate them recursively. The backward quantities G>d and H>d are computed once per iteration, and the forward quantities G<d+1 and H<d+1 are updated right after core d is updated, so each core needs only one extra contraction. The mean Eq[G\d] uses the posterior means of the cores, whereas the Gram matrices also include the posterior covariances through (21). The updates are sequential as in ALS: cores k<d use their values from the current iteration and cores k>d from the previous one.
When rank pruning is enabled, it is applied at every iteration after the initial five. For each rank d∈[2,D], we define the variance explained by rank component rd as ∥W~::rd(d−1)∥F2+∥W~rd::(d)∥F2, the squared norm of its associated frontal and horizontal slices, normalized over all components of Rd. The component rd is removed if its variance explained is below a threshold ϵ, set to 10−3% by default, while at least the largest component is always retained. This removes the corresponding slices of both neighboring cores, the matching rows and columns of their covariances, and the associated λrd together with its posterior parameters. Convergence is defined as the point at which the relative change in the lower bound between consecutive iterations falls below a user-defined threshold of 10−4; otherwise,
Figure 3: Variance explained (%) per rank component of each TT rank Rd, together with the posterior mean log-precisions logλ~d.
training is stopped when the maximum number of iterations is reached. Since pruning changes the ranks, the lower bound is not guaranteed to be non-decreasing at iterations where components are removed.
The cost per iteration is dominated by the core updates. For each core, forming Eq[G\dG\d⊤] costs O(N(MR2)2) and inverting the RdMdRd+1-dimensional precision matrix costs O((MR2)3). The total is therefore O(ND(MR2)2+D(MR2)3). The hyperparameter updates are of lower order. This matches the cost of deterministic TT-ALS (Holtz et al., 2012; Batselier et al., 2017), so uncertainty quantification comes at no extra asymptotic computational cost. The only additional requirement is storing the covariances Σ(d), which takes O(D(MR2)2) memory.
3.4.3 VARIANCE NORMALIZATION
This subsection discusses the growth of the predictive variance in (40) and introduces a normalization strategy. The total variance term Si−1 combines the observation noise with the uncertainty in the TT cores, where each quadratic form Eq[g\d(xi)]⊤Σ(d)Eq[g\d(xi)] measures the contribution of the dth core. Each of these quadratic forms is taken over the RdMdRd+1 entries of the corresponding core, and since the mean-field approximation assumes independence across cores, the D contributions accumulate additively. Consequently, the predictive variance grows with the total number of core entries, and thus with the feature dimensions, the resulting TT ranks, and the number of modes. We therefore normalize the aggregated quadratic-form term ∑d=1DEq[g\d(xi)]⊤Σ(d)Eq[g\d(xi)] by the number of latent degrees of freedom ∑d=1DRdMdRd+1, evaluated at the ranks of the trained model, while leaving the noise term bN/aN unchanged.
4 Effect of penalization on synthetic data
To illustrate the effect of the penalization induced by λd and δd on the TT cores, we consider a synthetic experiment constructed analogously to the CPD case (Kilic and Batselier, 2025). The entries of the input matrix X∈RN×D are sampled independently from a standard normal distribution, with N=100 and D=4, so that the tensor train has three TT ranks R2, R3 and R4. The inputs are mapped to pure-power features with Md=5 for every core.
Figure 4: Variance explained (%) per feature component of each core, together with the posterior mean log-precisions logδ~d.
The ground-truth TT cores have ranks Rd=3, are drawn from N(0,I) and scaled by 10, and have nonzero entries only for the first three features of every core, so that the true feature dimension is 3. The outputs are generated as y=Φ⊤w+e, with e∼N(0,σe2I) and σe=10−3.
The model is initialized with Rd=Md=5 for every core, i.e., larger than the true values, and with hyperparameters a0=b0=10−3 and c0=e0=g0=h0=10−6. Rank pruning is disabled, so that the shrinkage of all components remains visible, and the model is trained for the full 100 iterations without the convergence criterion of Section 3.4.2. The lower bound shows a convergence behavior similar to the CPD case (Kilic and Batselier, 2025) and stabilizes well within 50 iterations, so a maximum of 50 iterations is sufficient in practice. We report the variance explained by each rank component, as defined in Section 3.4.2, and analogously the variance explained by feature component md of core d as ∥W~:md(d)∥F2, normalized over all features of that core.
Figure 3 shows the variance explained per rank component together with logλ~d, the posterior mean rank precisions defined below (38). For each TT rank, two of the five components shrink to zero, correctly recovering the true rank of 3. The inactive components explain at most 8.3×10−5% of the variance, whereas the smallest active component explains 7.6%, so the inferred ranks are insensitive to the pruning threshold over a wide range. The inactive components also receive the largest precisions of their rank; for R3, for example, they have precisions of approximately 180, compared with 3.6 to 6.0 for the active ones. Since the overall magnitude of λ~d differs between ranks, precisions are comparable within each rank. Finally, the active components differ between ranks, e.g., components 1, 2 and 4 for R2 and components 2, 4 and 5 for R4. This is expected, since both the TT representation and the prior in (6) are invariant to permutations of the rank index, so the prior determines how many components are relevant but not which ones.
Figure 4 shows the corresponding results for the feature components, together with logδ~d, the posterior mean feature precisions defined below (38). Unlike the rank components, each feature corresponds to a fixed basis function, so the relevant features are identifiable. In every core, the three true features carry the variance, with the smallest of them still explaining 9.1%, while each of the two irrelevant features explains at most 0.015%. Likewise, the irrelevant features receive the largest entries of δ~d, two to four orders of magnitude above those of the true features of the same core. For the fourth core, for instance, the irrelevant features have precisions above 4⋅104, compared with values between 6 and 53 for the true ones. As for the ranks, precisions are compared within each core.
Taken together, these results show that learning λd and δd recovers the true TT ranks and feature dimensions at every rank and core, yielding a compact TT representation from an over-parameterized initialization.
5 Conclusion
We have presented Bayesian Tensor Train Kernel Machines (BTT-KM), a Bayesian treatment of TT kernel machines that places hierarchical, ARD-type priors on the TT cores and infers the TT ranks and feature dimensions directly from data. Approximating the posterior with mean-field variational inference yields a Bayesian alternating least squares algorithm with the same computational complexity as deterministic TT-ALS, so uncertainty quantification and automatic complexity inference are obtained at no additional asymptotic cost.
Each TT rank is governed by its own precision vector λd, shared between the two neighboring cores, while each core has its own feature precisions δd. In the synthetic experiment, this penalization recovers the true rank at every TT rank and the true feature dimension at every core from an over-parameterized initialization, with active and inactive rank components separated by several orders of magnitude. Since both the TT representation and the prior are invariant to permutations of each rank index, the prior identifies how many rank components are relevant but not which ones. The feature components, in contrast, correspond to fixed basis functions and are therefore identifiable, although irrelevant features are typically shrunk to small but nonzero values rather than to zero.
This publication is part of the project Sustainable learning for Artificial Intelligence from noisy large-scale data (with project number VI.Vidi.213.017) which is financed by the Dutch Research Council (NWO).
References
K. Batselier, Z. Chen, and N. Wong. Tensor Network alternating linear scheme for MIMO Volterra system identification. Automatica, 84:26–35, 2017. doi: 10.1016/j.automatica.2017.06.033.
J. D. Carroll and J.-J. Chang. Analysis of individual differences in multidimensional scaling via an N-way generalization of “Eckart–Young” decomposition. Psychometrika, 35(3):
283–319, 1970. doi: 10.1007/BF02310791.
R. A. Harshman. Foundations of the PARAFAC procedure: Model and conditions for an “Explanatory” multi-mode factor analysis. Technical Report 16, UCLA Working Papers in Phonetics, 1970.
S. Holtz, T. Rohwedder, and R. Schneider. The alternating linear scheme for tensor optimization in the tensor train format. SIAM Journal on Scientific Computing, 34(2): A683–A713, 2012. doi: 10.1137/100818893.
A. Kilic and K. Batselier. Interpretable Bayesian tensor network kernel machines with automatic rank and feature selection, Jul. 2025. arXiv:2507.11136.
D. J. C. MacKay. Bayesian methods for backpropagation networks. In E. Domany, J. L. van Hemmen, and K. Schulten, editors, Models of Neural Networks III, chapter 6, pages 211–254. Springer, 1994.
R. M. Neal. Bayesian Learning for Neural Networks, volume 118 of Lecture Notes in Statistics. Springer, New York, NY, 1996.
A. Novikov, M. Trofimov, and I. Oseledets. Exponential machines. Bull. Pol. Acad. Sci. Tech. Sci., 66:789–797, 2018. Special Section on Deep Learning: Theory and Practice.
I. V. Oseledets. Tensor-train decomposition. SIAM Journal on Scientific Computing, 33(5):2295–2317, 2011. doi: 10.1137/090752286.
J. A. K. Suykens, T. V. Gestel, J. D. Brabanter, B. D. Moor, and J. Vandewalle. Least Squares Support Vector Machines. World Scientific, Singapore, 2002.
F. Wesel and K. Batselier. Large-scale learning with Fourier features and tensor decompositions. In Proc. 35th Adv. Neural Inf. Process. Syst., pages 17543–17554, 2021.
F. Wesel and K. Batselier. Quantized Fourier and Polynomial Features for more expressive tensor network models. arXiv preprint, arXiv:2309.05436, 2024. URL https://arxiv.org/abs/2309.05436.
F. Wesel and K. Batselier. Tensor network-constrained kernel machines as Gaussian processes. In Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, pages 2161–2169. PMLR, 03–05 May 2025. URL https://proceedings.mlr.press/v258/wesel25a.html.
J. M. Winn and C. M. Bishop. Variational message passing. Journal of Machine Learning Research, 6:661–694, 2005.
Q. Zhao, L. Zhang, and A. Cichocki. Bayesian CP factorization of incomplete tensors with automatic rank determination. IEEE Trans. Pattern Anal. Mach. Intell., 37(9): 1751–1763, 2015. doi: 10.1109/TPAMI.2015.2392756.
Appendix
This appendix collects the proofs and derivations supporting the main text. We refer the reader to Bishop (2006)a for background on variational inference and exponential families.
In variational Bayesian (VB) inference, the intractable posterior p(Θ∣y) is approximated by a factorized distribution q(Θ)=∏jqj(θj), where each factor is updated via
lnqj(θj)=Eq(Θ∖θj)[lnp(y,Θ)]+const.
When the resulting expression matches the log of a known distribution, the update is available in closed form. Section 1 proves Theorem 4, which isolates the dth core in the model output, and Section 2 expands the log-joint distribution. Section 3 derives the TT core update, whose expected Gram matrix is evaluated by Theorem 6 (proved in Section 4) and the forward and backward Gram recursions (Section 5). Sections 6-8 derive the posteriors of the feature precisions, rank precisions and noise precision. Section 9 derives the ELBO used as the convergence criterion, and Section 10 the approximate predictive distribution.
Throughout the posterior derivations, exponential family posteriors are identified by completing the square or by matching coefficients with the log of a known distribution.
a. C. M. Bishop, Pattern Recognition and Machine Learning, Springer, New York, 2006.
1. Proof of Theorem 4
Proof [Theorem 4] We rewrite the data fitting term Φ⊤w in two equivalent forms. The first isolates W(d), giving the design matrix G\d needed for the core updates. The second is the full model expression used in the residual computations.
where ⊛ denotes the element-wise product and G<D+1 is obtained by continuing the forward recursion through all D cores. This expression is used to evaluate the posterior expectation of the squared residual.
The log of the joint distribution We expand the log of the joint distribution p(y,Θ) by substituting the likelihood and all priors, and collect terms by parameter. The resulting expression is the starting point for all variational updates, since each posterior qj(θj) is obtained by taking the expectation of this log-joint over all parameters except θj.
Here, the boundary rank precisions associated with R1=RD+1=1 are fixed and therefore do not contribute to the corresponding logarithmic terms.
This form of the log of the joint distribution will be used frequently in variational Bayesian inference, because the inference of each Θj can be done by
lnqj(Θj)=Eq(Θ\Θj)[lnp(y,Θ)]+const.
TT core update We derive the variational posterior of vec(W(d)) by collecting only the terms in the log-joint that depend on W(d). The residual term is rewritten using the design matrix G\d, and expanded into a quadratic form in vec(W(d)).
Proof [Theorem 6] We rewrite the expected Gram matrix Eq[G\dG\d⊤] in terms of the left and right TT contractions, which can be evaluated recursively. This exploits the column-wise Kronecker structure of the Khatri–Rao product: by the transpose and mixed-product properties of the Kronecker product,
(A⊗B)⊤=A⊤⊗B⊤,(A⊗B)(C⊗D)=(AC)⊗(BD),
the outer product of each column of G\d splits into left, feature, and right factors. Since Φ(d) is deterministic and the cores {W(k)}k=d are mutually independent under q, the expectation then factorizes over the left and right factors.
Derivation of the Gram recursions Let P denote the fixed permutation matrix that reorders the Kronecker factors according to the adopted index ordering. Using the mixed-product property of the Khatri–Rao product,
(AX)⊙(AX)=(A⊗A)(X⊙X),
with X=B⊙C gives
(A(B⊙C))⊙(A(B⊙C))=(A⊗A)[(B⊙C)⊙(B⊙C)].
For each column n,
(bn⊗cn)⊗(bn⊗cn)=P[(bn⊗bn)⊗(cn⊗cn)].
Hence,
(B⊙C)⊙(B⊙C)=P[(B⊙B)⊙(C⊙C)],
and therefore
(A(B⊙C))⊙(A(B⊙C))=(A⊗A)P[(B⊙B)⊙(C⊙C)].(41)
Forward accumulator. Given the definition G<k:=W(3)(k−1)(Φ(k−1)⊙G<k−1), take A=W(3)(k−1), B=Φ(k−1), and C=G<k−1 in (41)
Since W(k−1) is independent of the preceding TT cores, the expectation factorizes as above. Together with the boundary condition H<1=1N⊤, this is precisely the forward recursion, and hence H<k=Eq[G<k⊙G<k].
Backward accumulator. Given the definition G>k:=W(1)(k+1)(G>k+1⊙Φ(k+1)), take A=W(1)(k+1), B=G>k+1, and C=Φ(k+1) in (41)
Since W(k+1) is independent of the subsequent TT cores, the expectation factorizes as above. Together with the boundary condition H>D=1N⊤, this is precisely the backward recursion, and hence H>k=Eq[G>k⊙G>k].
The variational posterior distribution of hyperparameter δd We derive the variational posterior of δd by collecting only the terms in the log-joint that depend on δd.
Here, Var applied to a vector denotes the vector of its marginal variances.
The variational posterior distribution of hyperparameter λd We derive the variational posterior of λd by collecting only the terms in the log-joint that depend on λd. Since λd is shared between the (d−1)th and dth TT cores, both cores contribute to its posterior.
The variational posterior distribution of hyperparameter τ We derive the variational posterior of τ by collecting only the terms in the log-joint that depend on τ.
Thus we observe that the posterior is a Gamma distribution with updated parameters:
aN=a0+2N,bN=b0+21Eq[∥y−Φ⊤w∥F2].
Lower bound model evidence We expand the ELBO into expected log-likelihood, expected log-prior, and posterior entropy terms for each group of parameters, evaluate each using the posterior parameters, and collect them into the compact form used as the convergence criterion.
All expectations are with respect to the posterior q. The first term is the expected log-likelihood, followed by expected log-priors on {W(d)}d=1D, {δd}d=1D, {λd}d=2D, and τ; the final four terms are the corresponding posterior entropies. In the following expressions, ψ(⋅) denotes the digamma function and Γ(⋅) denotes the Gamma function. The boundary rank precisions are fixed at Λ1=ΛD+1=[1], with R1=RD+1=1, and have no hyperprior or posterior entropy terms. Each term can be computed by
Finally, the lower bound can be computed using the posterior parameters of all unknowns in Θ, where the posterior parameters are updated at each iteration.
Predictive Distribution We marginalize sequentially over each TT core W(d) via a Gaussian-Gaussian approximation, adding one variance term per mode, and then over τ with its Gamma posterior, yielding an approximate Student's t-distribution. Note that the true posterior p(Θ∣y) is approximated by q(Θ), whose factors were derived in Sections 3, 6, 7, and 8.