Year: 2018

Abstract:
The Tensor-Train factorization (TTF) is an efficient way to compress large weight matrices of fully-connected layers and recurrent layers in recurrent neural networks (RNNs). However, high Tensor-Train ranks for all the core tensors of parameters need to be element-wise fixed, which results in an unnecessary redundancy of model parameters. This work applies Riemannian stochastic gradient descent (RSGD) to train core tensors of parameters in the Riemannian Manifold before finding vectors of lower Tensor-Train ranks for parameters. The paper first presents the RSGD algorithm with a convergence analysis and then tests it on more advanced Tensor-Train RNNs such as bi-directional GRU/LSTM and Encoder-Decoder RNNs with a Tensor-Train attention model. The experiments on digit recognition and machine translation tasks suggest the effectiveness of the RSGD algorithm for Tensor-Train RNNs.

heading: 1 INTRODUCTION
text: Recurrent Neural Networks (RNNs) are typically composed of large weight matrices of fullyconnected and recurrent layers, thus massive training data as well as exhaustive computational resources are required. The Tensor-Train factorization (TTF) aims to reduce the redundancy of RNN parameters by reshaping large weight matrices into high-dimensional tensors before factorizing them in a Tensor-Train format Oseledets (2011). The notation of Tensor-Train usually suggests that TTF is applied for the tensor representation of model parameters. Tensor-Train was initially applied to fully-connected layers Novikov et al. (2015), and it has been recently generalized to recurrent layers in RNNs such as LSTM and GRU Yu et al. (2017). Compared with other tensor decomposition techniques like the CANDECOMP/PARAFAC decomposition Kolda & Bader (2009) and Tucker decomposition Kim & Choi (2007), Tensor-Train can be easily scaled to arbitrarily high dimensions and have the advantage of computational tractability to significantly large weight matrices.
Given a vector of Tensor-Train ranks r = (r1, r2, · · ·, rd+1), TTF decomposes a d-dimensional tensor W ∈ R(m1·n1)×(m2·n2)×···×(md·nd) into a multiplication of core tensors according to (1), where the k-th core tensor C[k] ∈ Rrk×mk×nk×rk+1 , and any index pair (ik, jk) satisfies 1 ≤ ik ≤ mk, 1 ≤ jk ≤ nk. Additionally, the ranks r1 and rd+1 are fixed to 1.
W((i1, j1), (i2, j2), ..., (id, jd)) = C [1](r1, i1, j1, r2)C [2](r2, i2, j2, r3)···C[d](rd, id, jd, rd+1) (1)
Thus, when the TTF technique is applied to the fully-connected (FC) layer with feed-forward weight matrix W , a tensor W is firstly converted from W and is then decomposed to a multiplication of the core tensors as shown in (2), where C[t] is the t-th core tensor, X denotes a tensor of input, B refers to a tensor of bias, the tensor of outputs Ŷ ∈ Rn1×n2×···×nd , and σ is a sigmoid function. For clarity, the notation TTL(W ,X) is used to simplify the representation of a Tensor-Train fully-connected layer, which is shown in (3).
Ŷ(j1, j2, ..., jd) = σ( m1∑ i1=1 · · · md∑ id=1 d∏ t=1 C[t](rt, it, jt, rt+1)X(i1, i2, ..., id) + B(j1, j2, ..., jd)) (2)
Ŷ = σ(TTL(W ,X)). (3)
Likely, we use (4) to represent an RNN with a feed-forward weight matrix W and a recurrent weight matrix U . In (4), Xt is an input matrix at time t, ht−1 and ht separately denote the hidden vectors of time t− 1 and t, and σ refers to the sigmoid function.
ht = σ(TTL(W ,Xt) + TTL(U ,ht−1)). (4)
The largest benefit from Tensor-Train models is the capability to reduce the model parameters tremendously. For example, a Tensor-Train FC layer needs ∑ imi · ni · ri · ri+1 parameters in
total. In comparison, the total number of parameters of an FC layer is about O( ∏ imi · ∏
i ni), which is much larger than the associated Tensor-Train FC one.
The Tensor-Train models are found widespread. For example, Yang et al. (2017) set up Tensor-Train Recurrent Neural Networks for video classification, and Yu et al. (2017) applied the Tensor-Train as an End-to-End dynamic model for multi-variate forecasting environmental data. However, those applications focused on simple deep learning architectures, and a vector of Tensor-Train ranks r is element-wise fixed. When more complex deep models with numerous Tensor-Train layers are involved, it is not easy to find appropriate Tensor-Train ranks for each core tensor. However, when applying a vector of shared and high Tensor-Train ranks to all parameters of Tensor-Train layers, each of them has a vector of lower Tensor-Train ranks, which results in an additional decrease in the number of parameters.
This work applies Riemannian Stochastic Gradient Descent (RSGD) to the RNN Tensor-Train layers. Unlike Stochastic Gradient Descent (SGD), which conducts the update of parameters in the Euclidean space, RSGD finds optimal core tensors of parameters associated with a vector of lower Tensor-Train ranks in Riemannian Manifold, thereby decreasing the number of total parameters of Tensor-Train RNNs.
Our work is inspired by Bonnabel (2013) and Lubich et al. (2015), which are two excellent introductions to the theory of Stochastic Gradient Descent on Riemannian Manifolds. Additionally, Zhang et al. (2016) was a recent work that proposed a fast stochastic optimization on Riemannian Manifolds. Besides, Absil et al. (2009) is a useful reference of Riemannian optimization.
Contributions. We summarize the key contributions of this paper as follows:
• This work applies RSGD to iteratively find vectors of lower Tensor-Train ranks with the update of parameters in the training process. The RSGD algorithm and the related theoretical analysis are also presented.
• We design Bi-directional Tensor-Train GRU/LSTM Chung et al. (2014), and EncoderDecoder Tensor-Train RNNs with a Tensor-Train Attention mechanism Luong et al. (2015). We apply the RSGD algorithm to the Tensor-Train RNN models on the digit recognition and machine translation tasks.
To the best of our knowledge, this is the first work that applies RSGD to train Tensor-Train RNNs to find the optimal core tensors of parameters with vectors of lower Tensor-Train ranks. Moreover, this is the first work that builds Tensor-Train RNNs with complex architectures for natural language processing (NLP) tasks.

heading: 2 RIEMANNIAN STOCHASTIC GRADIENT DESCENT
text: The optimization problem of Tensor-Train RNNs can be formulated as a Riemannian optimization problem as shown in (5), where {X,Y } is a data sequence with length T , W represents a tensor of parameters which lies in a d-dimensional Riemannian Manifold (M,µ) with a Riemannian measure µ , and the Tensor-Train ranks for core tensors of W must be element-wise no higher than the vector r = (r1, r2, ..., rd+1) as shown in (5).
min W∈M
f(W;X,Y )
s.t., tt rank(W) ≤ r. (5)
Besides, the Riemannian measure µ induces an inner product structure in each tangent space TxM associated with a tensor x ∈M . Specifically, ∀u, v ∈ TxM , the inner product < u, v >= µx(u, v).
Algorithm 1 Riemannian Stochastic Gradient Descent 1. Given the labeled input data (X,Y ) with sequence length T , and the learning rate η. 2. W(0)← the randomly initialized core tensors {C[1],C[2], ...,C[d]}. 3. For t = 1, 2, ..., T : 4. For i = 1, 2, ..., d: 5. Choose a gradient gC[i] = ∇C[i]f(W
(t);X,Y ) in the tangent space TC[i]M . 6. Âi = C[i] − ηgC[i] . 7. Ĉ
[i] ← ExpC[i](Âi).
8. (Ĉ [i] , r̂i)← rounding(Ĉ [i] ). 9. W(t) ← {Ĉ [1] , Ĉ [2] , · · ·Ĉ [d] }. 10. r← (r̂1, r̂2, ...r̂d). 11. Reshape the core tensors {C[1],C[2], ...,C[d]} based on the updated r. 12. Return W(T+1) = {C[1],C[2], · · ·,C[d]}.
Similarly, µ induces the norm of u ∈ TxM as ||u|| = √ µx(u,u) ≥ 0. In addition, the µ induced inner product and the norm preserve the basic properties like definiteness, homogeneity and triangle inequality.
Algorithm 1 presents the RSGD Algorithm. The algorithm mainly consists of two main procedures: one is the update of parameters in the tangent space and conducting an exponential mapping, and the second one is the rounding to lower Tensor-Train ranks. As illustrated in Figure 1, step 5 firstly obtains a gradient gC[i] on a tangent space TCiM at the core tensor C
[i] in Riemannian Manifold (M,µ), and step 6 conducts a gradient descent on the tangent space to generate a new tensor Âi. Step 7 projects Âi back to Ĉ [i] in Riemannian Manifold (M,µ) by an exponential mapping. Finally, as shown in Figure 2, the rounding function in step 8 transforms Ĉ [i] in the submanifold Sr to the core tensor Ĉ [i]
with a vector of lower Tensor-Train ranks r̂ in a new submanifold Sr̂. Note that the vectors of Tensor-Train ranks r and r̂ span two submanifolds Sr ⊂ M and Sr̂ ⊂ M respectively. After that, the next iteration of the the parameter update is conducted in Sr̂.
The exponential mapping in Algorithm 1 is formulated in (6). Unfortunately, it is not easy to solve the problem because we have to deal with the calculus of variations, or we have to know the Christoffel symbols Lubich et al. (2015). Therefore, a fast and straightforward retraction method is applied as a first-order approximation to the exponential mapping as shown in Algorithm 2.
min Y∈Sr⊂Md
||W− Y||F
s.t., tt rank(Y) = r. (6)
Algorithm 2 The Retraction Algorithm
1. Given the core tensors {C[1],C[2], · · ·,C[d]} and the Tensor-Train rank r̂ = {r1, r2, · · ·, rd+1}. 2. For i = 1 to d: 3. Ai ← reshape C[i] by the shape of (ri · ni ·mi)× ri+1. 4. For i = 1 to d: 5. Âi,Σi ← QR decomposition(Ai). 6. C[i] ← reshape Âi by (ri, ni,mi, ri+1). 7. Ai+1 ← multiply(Σi, Ai+1), if i < d. 8. Return {C[1],C[2], · · ·,C[d]}.
Algorithm 3 The Rounding Algorithm
1. Given the core tensors {C[1],C[2], · · ·,C[d]} and a constant maximum rank rmax. 2. Initialize r̂ = {1, 1, ..., 1}. 3. For i = 1 to d: 4. Ai ← reshape C[i] by the shape of (ri · ni ·mi)× ri+1. 5. For i = 1 to d: 6. col num(C[i]) = ni ·mi · r̂i+1. 7. row num(C[i]) =
ri · ri+1 r̂i+1 .
8. r̂i+1 = min(rmax, col num(C[i]), row num(C[i])). 9. (Ui,Si,Vi) = SVD(Ai). 10. Ûi = Ui[:, 1 : r̂i+1], Ŝi = Si[1 : r̂i+1, 1 : r̂i+1], V̂i = Vi[1 : r̂i+1, :]. 11. Âi = ÛiŜiV̂i. 12. C[i] ← reshape Âi as Rr̂i×ni×mi×r̂i+1 . 13. Return the updated core tensors {C[1],C[2], · · ·,C[d]}.
Algorithm 2 presents the retraction algorithm. The main idea of the retraction algorithm is to orthogonalize the core tensors {C[1],C[2], · · ·,C[d]} in a left-to-right order by the QR decomposition. The rounding algorithm is shown in Algorithm 3. Similar to the retraction algorithm, a left-to-right tensor matricization is firstly initialized. Then, the Tensor-Train rank is updated before conducting an SVD computation. The returned core tensors {C[1],C[2], · · ·,C[d]} are based on the updated vector of lower Tensor-Train ranks. Furthermore, the rounding procedure has the property presented in Proposition 1.
Proposition 1. The rounding procedure of Algorithm 3 does not change values of the objective function f for the Tensor-Train RNNs. That is, for a tensor x ∈ Sr, the rounding tensor x̂ ∈ Sr̂, we have f(x̂) = f(x).
Proof. Given the weight matrix W with core tensors {C[1],C[2], · · ·,C[d]}, for an input tensor X ∈M , we obtain (7) and (8) according to (1).
Y(j1, j2, ..., jd) = m1∑ i1=1 · · · md∑ id=1 d∏ t=1 C[t](rt, it, jt, rt+1)X(i1, i2, ..., id) + B(j1, j2, ..., jd) (7)
= m1∑ i1=1 · · · md∑ id=1 d∏ t=1 C[t](r̂t, it, jt, r̂t+1)X(i1, i2, ..., id) + B(j1, j2, ..., jd), (8)
which suggests that a vector of Tensor-Train ranks determines a submanifold for generating core tensors of the tensor W, but the values of the objective functions are invariant to the change of the vector of Tensor-Train ranks, obtaining Proposition 1.

heading: 3 CONVERGENCE ANALYSIS
text: This section analyzes the convergence of the RSGD algorithm. The necessary definitions and theorems are firstly introduced, and the analysis is then provided. Since the objective functions of Tensor-Train RNNs are always geodesically non-convex Zhang et al. (2016), we only consider the convergence of RSGD for non-convex cases.
Definition 2. A different function f : M → R is geodesically L-smooth if its first-order gradient is geodesically L-Lipchitz continuous. Specifically, ∀x,y ∈M we have 9.
f(y) ≤ f(x)+ < gx, Exp−1x (y) > + L
2 ||Exp−1x (y)||2, (9)
where gx is the sub-gradient of f(x) at x in the tangent space TxM , and Exp−1x (y) is the inverse exponential mapping which projects the curve line in Md from x to y back to the gradient x in the tangent space TxM .
From the RSGD algorithm (Algorithm 1), it is not hard to find the sub-gradient gx = ∇f(x) and Exp−1x (y) = −η∇xf(x), and thus Theorem 3 can be derived. Theorem 3. For a differentiable and geodesically L-smooth function f , the Riemannian stochastic gradient descent algorithm ensures (10).
min t E[||∇f(xt)||] ≤
1
ηT (f(x0)− f(x∗)) +
L 2 η2k2, (10)
where T refers the total iterations, x0 and x∗ denote the initial and the optimal points respectively, η is the learning rate, and ||Exp−1x (y)||2 is bounded by η2k2.
Proof. Assume x∗ and x0 separately refer to the optimal and initial points. For all xt and xt+1 at two consecutive times, we can derive (11) based on Definition 2.
E[f(xt+1)] ≤ E[f(xt)] + E[< ∇f(xt), Exp−1xt (xt+1) >] + L 2 E[||Exp−1xt (xt+1)|| 2]. (11)
By applying Exp−1xt (xt+1) = −η∇f(xt)) and E[||Exp −1 xt (xt+1)|| 2] ≤ η2k2, we obtain (12), where x̂t+1 is the rounding tensor of x̂t+1. The Proposition 1 ensures that f(xt+1) = f(x̂t+1).
E[||∇f(xt)||] ≤ 1
η E[f(xt)− f(xt+1)] +
L 2 η2k2 = 1 η E[f(xt)− f(x̂t+1)] + L 2 η2k2. (12)
By summing the two sides of equation 12 from 0 to T − 1, we derive (13).
min t E[||∇f(xt)||] ≤
1
T T−1∑ t=0 E[||∇f(xt)||] ≤ 1 ηT (f(x0)− f(xT )) + L 2 η2k2. (13)
Since f(xt) ≤ f(xT ),∀0 ≤ t ≤ T − 1, we have 14.
min t E[||∇f(xt)||] ≤
1
ηT (f(x0)− f(xT )) +
L 2 η2k2 ≤ 1 ηT (f(x0)− f(x∗)) + L 2 η2k2. (14)
After rounding x∗ to x̂∗ , we finally obtain the result 15 of Theorem 3.
min t E[||∇f(xt)||] ≤
1
ηT (f(x0)− f(x̂∗)) +
L 2 η2k2. (15)
Furthermore, Theorem 3 suggests that the number of iterations T satisfies (16) before reaching the convergence.
T ≤ f(x0)− f(x̂ ∗)
η(min t E[||∇f(xt)||]− L2 η2k2)
. (16)

heading: 4 ADVANCED TENSOR-TRAIN RNNS
text: This section introduces the Tensor-Train RNNs with the advanced architectures used in this work. The new Tensor-Train architecture is based on the Bi-directional Tensor-Train GSU/LSTM. The other one is the Tensor-Train Encoder-Decoder RNNs with the Tensor-Train Attention mechanism.

heading: 4.1 BI-DIRECTIONAL TENSOR-TRAIN GRU/LSTM
text: Firstly, we introduce the Bi-directional Tensor-Train GRU/LSTM, which involves twice more parameters than the Tensor-Train GRU/LSTM. Equations from (17) to (24) present the functional mechanisms of the Bi-directional Tensor-Train GRU, where the pairs (−→rt ,←−rt ) and (−→zt ,←−zt) denote forward and backward update gate operations, respectively, and the pair ( −→ dt, ←− dt) represents the forward-backward reset gate operations. In addition, the pair ( −→ ht, ←− ht) is the memory cell holding information of last times. oh is the output of the Bi-directional Tensor-Train GRU which combines−→ ht and ←− ht by concatenating them before feeding through a Tensor-Train linear layer.
−→rt = σ(TTL( −→ W r, −→ Xt) + TTL( −→ U r, −−→ ht−1)) (17) ←−rt = σ(TTL( ←− W r, ←− Xt) + TTL( ←− U r, ←−− ht−1)) (18) −→zt = σ(TTL( −→ W z, −→ Xt) + TTL( −→ U z, −−→ ht−1)) (19) ←−zt = σ(TTL( ←− W z, ←− Xt) + TTL( ←− U z, ←−− ht−1)) (20)
−→ dt = tanh(TTL( −→ W d, −→ Xt) + TTL( −→ U d, (−→rt ◦ −−→ ht−1))) (21) ←− dt = tanh(TTL( ←− W d, ←− Xt) + TTL( ←− U d, (←−rt ◦ ←−− ht−1))) (22)
−→ ht = (1−−→zt) ◦ −−→ ht−1 + −→zt ◦ −→ dt, ←− ht = (1−←−zt) ◦ ←−− ht−1 + ←−zt ◦ ←− dt (23)
oh = σ(TTL(Ah, [ −→ ht; ←− ht])). (24)
In addition, we also design a Bi-directional Tensor-Train LSTM which involves more operational gates than the Bi-directional Tensor-Train GRU.

heading: 4.2 THE TENSOR-TRAIN ENCODER-DECODER RNNS WITH ATTENTION MODELS
text: The Encoder-Decoder RNNs are commonly used in sequence-to-sequence deep learning applications. Moreover, the attention mechanism significantly improves the performance of EncoderDecoder RNNs Vaswani et al. (2017).
The Bi-directional Tensor-Train RNN like GRU or LSTM is used to construct the Encoder-Decoder architecture. Moreover, we set up the Tensor-Train Attention model in addition to the Tensor-Train Encoder-Decoder RNNs. Thus, the entire model is built on Tensor-Train layers.
To build a Tensor-Train Attention model, it is necessary to add the Tensor-Train layer to generate an Attention vector as shown in (25), where ct is a context vector (26) with attention weights αts (27), at is the output of the Attention model at time t, h̄s denotes a vector built from the outputs of the forward and backward stages, and ht refers to the output of the hidden layers at time t.
at = tanh(TTL(Wc, [ct;ht])) (25) ct = ∑ s αtsh̄s (26)
αts = exp(score(ht, h̄s))∑S
s′=1 exp(score(ht, h̄s′)) . (27)

heading: 5 APPLICATIONS
text: This section first introduces the implementation of the Tensor-Tensor RNNs. Then, we present two applications where the RSGD algorithms were tested. One application is the digit recognition task on the sequential MNIST dataset; the other is the task of machine translation on the Multi30K dataset Elliott et al. (2016).

heading: 5.1 IMPLEMENTATIONS
text: We employed PyTorch to implement our Tensor-Train RNNs. The data structures of our implementations were partly built on the free Tensor-Train toolkit implemented by the tool Tensorflow Novikov et al. (2018). However, we employed the tool PyTorch to take the advantage of dynamic graph generation, which is much more useful for NLP tasks.

heading: 5.2 DIGIT RECOGNITION ON THE MNIST DATASET
text: The first application is the digit recognition task on the MNIST dataset. The dataset consists of 60000 data with 28 ∗ 28 pixels for each digital image. Instead of vectorizing the image pixels into a long vector as an input for a static deep neural network, image pixels are taken as data sequence where the time step is set to 28, and the input dimension is set to 28. In our experiments, the training and testing sets were separately composed of 50000 and 10000 data. 2000 data were selected from the training set for building a validation set, and they were not included in the training set.
As for the experimental setup, we applied both Bi-directional Tensor-Train GRU and Bi-directional Tensor-Train LSTM to the task. The dimension of the Manifold (M,µ) was set to d = 3, and the vector of Tensor-Train ranks was initialized with high and shared values r = (1, 10, 10, 1) for the Tensor-Train layers. The weight matrix of the input-hidden Tensor-Train layer was converted to the tensor with the shape (2 × 7 × 2) by (6 × 6 × 6), and the weight matrix of the hidden-hidden Tensor-Train layer was converted to the tensor with the shape (6×6×6) by (6×6×6). The RSGD algorithm with a learning rate 0.01 was applied to both Bi-directional Tensor-Train GRU/LSTM.
The results are shown in Figure 3, where we compared the Bi-directional Tensor-Train GRU/LSTM with the traditional Bi-directional GRU/LSTM regarding recognition error rates and number of parameters. Inspecting the recognition error rate, the Bi-directional Tensor-Train GRU obtains a result that is close to that of the traditional Bi-directional GRU/LSTM, and the performance of the Bidirectional Tensor-Train LSTM becomes a bit worse. Regarding comparison with the number of parameters, both Bi-directional Tensor-Train GRU/LSTM can significantly reduce the number of parameters by taking only 1% parameters of the Bi-directional GRU/LSTM at final. Notably, the RSGD algorithm further reduces the number of parameters of Bi-directional GRU/LSTM by lowering the Tensor-Train ranks.

heading: 5.3 MACHINE TRANSLATION ON THE MULTI30K DATASET
text: The next application is a machine translation task from Dutch to English on the Multi30K dataset. In the dataset, there are separately 29000, 1014, and 1000 sentence pairs for training data, validation data, and test data, respectively.
The Bi-directional Tensor-Train GRU was used to build the Encoder-Decoder architecture, and a Tensor-Train Attention model was added to the architecture. The RSGD algorithm with a learning rate 0.01 was applied to the Tensor-Train Encoder-Decoder RNNs with the Tensor-Train Attention model. An initial vector of Tensor-Train ranks was set as r = (1, 6, 6, 6, 1), and the weight matrix of hidden layers was converted to the tensor with the shape of (4× 4× 4× 4) by (4× 4× 4× 4). Besides, the baseline was based on the traditional Bi-directional GRU and LSTM-based EncoderDecoder architecture with the Attention model, where the Stochastic Gradient Descent algorithm with learning rate 0.001 was used to update parameters.
The experimental results are shown in Figure 4, and the statistics of parameters of hidden layers are shown in Table 1. The results in Figure 4 suggest that the Tensor-Train Encoder-Decoder RNN performs closer or even better than the Encoder-Decoder one, although the convergence speed of the Tensor-Train model is relatively slower in the first several iterations. On the other hand, Table 1 shows that RSGD leads to a further decrease in the number of parameters.

heading: 6 CONCLUSIONS
text: This paper presents the RSGD algorithm for training Tensor-Train RNNs including the related properties, implementations, and convergence analysis. Our experiments on digit recognition and machine translation tasks suggest that RSGD can work effectively on the Tensor-Train RNNs regarding performance and model complexity, although the convergence speed is relatively slower in the beginning stages. Our future work will consider two directions: one is to apply the RSGD algorithm to more Tensor-Train models and test it on larger datasets of other fields; and the second one is to generalize Riemannian optimization to the variants of the SGD algorithms and study how to speed up the convergence rate.

Review summaries:
In this paper, the authors proposed a new method to update the weights in RNN by SGD on Riemannian manifold.  Due to the properties of manifold learning, the updated weights in each iteration are contracted with a low-rank structure, such that the number of the parameters of TT can be automatically decreased during the training procedure. By using the new algorithm, the authors modified two types of sophisticated RNNs, i.e., bi-directional GRU/LSTM and Encoder-Decoder RNN. The experimental results validate effectiveness of the proposed method. How to determine the rank of the tensor networks in weight compression problem is indeed an important and urgent task, this paper does not clearly illustrate how RSGD can efficiently solve this problem.