Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

TensorTrainTools

Guides

  • TensorTrainTools Overview

Symbols

  • RandomTensorTrain
  • TensorTrainCompress
  • TensorTrainContract
  • TensorTrainDecomposition
  • TensorTrainHadamard
  • TensorTrainInnerProduct
  • TensorTrain
  • TensorTrainNorm
  • TensorTrainOrthogonalize
  • TensorTrainPlus
  • TensorTrainScale
RubenRanval`TensorTrainTools`
TensorTrainDecomposition
​
TensorTrainDecomposition
[t]
decomposes the numeric array tensor
t
into a tensor train, a list of rank-3 cores
{
A
1
,
A
2
…,
A
n
}
​
Details and Options
▪
TensorTrainDecomposition decomposes a numerical array of any rank into a Tensor Train (also known as a Matrix Product State) representation.
▪
The result is a list of rank-3 arrays
{
A
1
,
A
2
…,
A
n
}
where
n
is the number of dimensions of the input tensor.
▪
The bond dimension refers to the size of the internal contracted indices connecting adjacent tensor cores. It effectively dictates the rank and compression level of the Tensor Train.
▪
Each core
A
k
has dimensions
{
χ
k-1
,
d
k
,
χ
k
}
where
d
k
is the size of the
th
k
dimension of the input tensor, and
χ
k
is the bond dimension between cores k and k+1.
▪
The first core has
χ
0
=1
and the last core has
χ
n
=1
.
▪
The following options can be given:
"MaxBondDimension"
Infinity
maximum bond dimension χ at each core
Tolerance
0
truncation threshold
ε
Method
"SVD"
decomposition method
▪
With
Method
→ "QR", the function ignores "MaxBondDimension" and
Tolerance
and returns the exact decomposition.
QRDecomposition
does not provide singular values, so truncation is not available.
▪
With the default settings, TensorTrainDecomposition returns an exact decomposition with no truncation.
▪
Setting only
"MaxBondDimension"
controls memory: bond dimensions are capped at the specified value.
▪
Setting only
Tolerance
controls accuracy: bond dimensions adapt automatically to meet the error target.
▪
With
Method
→ "SVD", singular values are discarded until the sum of the squared discarded values reaches
2
ε
, where
ε
is the value specified by
Tolerance
.
▪
For more mathematical background on this algorithm, see the Wikipedia articles on Tensor Network and Matrix Product State.
​
Examples  
(7)
Basic Examples  
(1)
Decompose a simple 2×3×4 tensor into a Tensor Train with exact mathematical precision:
In[1]:=
tensor=RandomReal[1,{2,3,4}];​​tensor//MatrixForm
Out[1]//MatrixForm=
0.847338
0.21448
0.937994
0.988433
0.511721
0.343519
0.159504
0.10954
0.293368
0.981938
0.0382194
0.826166
0.9938
0.681778
0.721473
0.0140569
0.788157
0.218408
0.751931
0.606123
0.729557
0.677594
0.414111
0.145786
In[2]:=
TensorTrainDecomposition[tensor]
Out[2]=
TensorTrain
Cores: 3
Max χ: 4
Tensor dims: {2,3,4}

The underlying cores can be accessed with the "Cores" property:
In[3]:=
TensorTrain
Cores: 3
Max χ: 4
Tensor dims: {2,3,4}
["Cores"]
Out[3]=
{{{{-0.801956,0.597382},{-0.597382,-0.801956}}},{{{-0.460303,-0.133718,-0.489801,0.468487},{-0.594543,0.356838,-0.201702,-0.626958},{-0.657099,-0.155319,0.537927,0.268915}},{{0.0307311,0.582246,-0.435329,0.333059},{0.039545,0.615667,0.441332,0.36397},{-0.0187889,-0.33557,-0.213918,0.267817}}},{{{1.26522},{1.20165},{1.09235},{1.65644}},{{0.0209867},{-0.814381},{0.283008},{0.388124}},{{0.523402},{-0.135013},{-0.1399},{-0.209582}},{{-0.000402348},{-0.00521084},{-0.215149},{0.145969}}}}
Inspect the dimensions of the underlying cores forming the Tensor Train:
In[4]:=
Dimensions/@%
Out[4]=
{{1,2,2},{2,3,4},{4,4,1}}
Options  
(3)

Properties & Relations  
(1)

Possible Issues  
(1)

Neat Examples  
(1)

SeeAlso
SingularValueDecomposition
▪
QRDecomposition
RelatedGuides
▪
TensorTrainTools Overview
RelatedLinks
▪
Tensor network - Wikipedia
▪
Matrix product state - Wikipedia
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com