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`
TensorTrain
​
TensorTrain
[{
A
1
,
A
2
,…,
A
n
}]
represents a tensor in tensor train format with rank-3 cores
A
i
​
Details and Options
▪
A tensor train (also called a matrix product state, MPS) expresses a tensor of rank
n
as a chain of
n
rank-3 cores, typically storing far fewer elements than the dense tensor.
▪
Each core
A
i
must be a rank-3 array with dimensions
{
χ
i-1
,
n
i
,
χ
i
}
, where
n
i
is the
th
i
dimension of the represented tensor and
χ
i
are the bond dimensions.
▪
The boundary bond dimensions
χ
0
and
χ
n
must both equal 1, and the last dimension of each core must equal the first dimension of the following core.
▪
TensorTrain
validates its cores, issuing a message and returning
$Failed
if they do not form a valid tensor train.
▪
TensorTrain
[…]["Properties"]
gives a list of all available properties.
"Cores"
the list of rank-3 cores
"CoreCount"
the number of cores
"TensorDimensions"
the dimensions of the original tensor
"BondDimensions"
the internal bond dimensions of the tensor train
"ParameterCount"
the total number of stored core elements
"FullElementCount"
the number of elements of the represented dense tensor
"CompressionRatio"
ratio of dense element count to stored paramater count
"Tensor"
the original input tensor
"Diagram"
a tensor network diagram of the train
▪
Normal
[
TensorTrain
[…]]
gives the represented tensor as a dense array, contracting all bond indices. It is equivalent to
TensorTrainContract
[
TensorTrain
[…]]
.
▪
Length
[
TensorTrain
[…]] gives the number of cores.
▪
Standard arithmetic operators are supported when, and only when, all operands are tensor trains:
t1+t2+…
TensorTrainPlus
[t1,t2,…]
ct
(numeric
c
)
TensorTrainScale
[c,t]
-t
TensorTrainScale
[-1,t]
t1⊙t2⊙…
TensorTrainHadamard
[t1,t2,…]
▪
Expressions mixing tensor trains with other quantities return unevaluated.
Examples  
(2)
Basic Examples  
(1)
Construct a tensor train from two explicit cores:
In[1]:=
cores={RandomReal[{-1,1},{1,2,3}],RandomReal[{-1,1},{3,2,1}]};​​tt=TensorTrain[cores]
Out[1]=
TensorTrain
Cores: 2
Max χ: 3
Tensor dims: {2,2}

Extract properties from that tensor train:
In[2]:=
tt["BondDimensions"]
tt["CompressionRatio"]
Out[2]=
{3}
Out[2]=
1
3
Or visualize the tensor train in a tensor network diagram:
In[3]:=
tt["Diagram"]
Out[3]=
Normal
gives back the original dense tensor:
In[4]:=
Normal[tt]
Out[4]=
{{-0.338276,0.148707},{-0.664117,0.354542}}
Possible Issues  
(1)

RelatedGuides
▪
TensorTrainTools Overview
""

© 2026 Wolfram. All rights reserved.

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