Wolfram Language
Paclet Repository
Community-contributed installable additions to the Wolfram Language
Primary Navigation
Categories
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
Create a Paclet
Get Started
Download Definition Notebook
Learn More about
Wolfram Language
TensorNetworks
Guides
TensorNetworks
Tech Notes
Building Tensor Networks
Contraction Paths and Execution
Matrix Product States
A Working Tour of the Symmetry Functions
Tensor Networks Overview
Young Tableaux and Tensor Symmetries
Symbols
ActivateTensors
BinaryTensorNetwork
BinaryTensorNetworkQ
CanonicalPath
CanonicalPathQ
ContractIndices
ContractionTree
EinsteinSummation
GreedyContractionPath
HookFactor
HookLength
HookLengths
IndexedMultiply
InitializeTensorNetwork
MetricTensor
MetricTensorQ
MPSCanonicalForm
MPSCanonicalQ
MPSEntanglementEntropy
MPSNormalize
MPSNorm
MPSOverlap
MPSSchmidtValues
MPSTruncate
OptimalContractionPath
PartitionQ
PathIndexContractions
PathQ
PathToTreePath
RandomTensorNetwork
SchurDimension
SparseTensorNetwork
TableauColumns
TableauDimension
TableauRows
TableauShape
TableauSize
TableauWeylDimension
TensorNetworkAdd
TensorNetworkContraction
TensorNetworkContractions
TensorNetworkContract
TensorNetworkData
TensorNetworkDelete
TensorNetworkFreeIndices
TensorNetworkGraphData
TensorNetworkGraphQ
TensorNetworkIndexDimensions
TensorNetworkIndexGraph
TensorNetworkIndices
TensorNetwork
TensorNetworkQ
TensorNetworkRemoveCycles
TensorNetworkReplaceIndices
TensorNetworkSize
TensorNetworkTensors
TensorNetworkToNetGraph
ToTensorNetworkGraph
TransposePartition
TreePathQ
TreePathToPath
YoungProject
YoungSymmetrize
YoungTableau
YoungTableauQ
Wolfram`TensorNetworks`
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
g
r
a
p
h
]
y
i
e
l
d
s
T
r
u
e
i
f
g
r
a
p
h
i
s
a
v
a
l
i
d
a
n
n
o
t
a
t
e
d
t
e
n
s
o
r
-
n
e
t
w
o
r
k
g
r
a
p
h
,
a
n
d
F
a
l
s
e
o
t
h
e
r
w
i
s
e
.
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
g
r
a
p
h
,
T
r
u
e
]
p
r
i
n
t
s
d
i
a
g
n
o
s
t
i
c
m
e
s
s
a
g
e
s
w
h
e
n
g
r
a
p
h
f
a
i
l
s
v
a
l
i
d
a
t
i
o
n
.
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
T
r
u
e
]
i
s
t
h
e
c
u
r
r
i
e
d
f
o
r
m
:
i
t
r
e
t
u
r
n
s
a
p
r
e
d
i
c
a
t
e
t
h
a
t
,
a
p
p
l
i
e
d
t
o
a
g
r
a
p
h
,
r
u
n
s
t
h
e
v
e
r
b
o
s
e
c
h
e
c
k
.
D
e
t
a
i
l
s
a
n
d
O
p
t
i
o
n
s
▪
A valid tensor-network graph is a
G
r
a
p
h
in which every vertex carries two annotations: a
"
T
e
n
s
o
r
"
(the underlying array) and an
"
I
n
d
e
x
"
(a duplicate-free list of
S
u
p
e
r
s
c
r
i
p
t
or
S
u
b
s
c
r
i
p
t
labels).
▪
Two consistency rules must hold across the vertex annotations: each tensor's rank equals the length of its
"
I
n
d
e
x
"
list, and the sum of all tensor ranks equals the count of distinct indices across all vertices.
▪
E
d
g
e
s
i
n
t
h
e
g
r
a
p
h
m
a
y
c
a
r
r
y
{
s
r
c
i
,
t
g
t
j
}
t
a
g
s
i
d
e
n
t
i
f
y
i
n
g
w
h
i
c
h
o
u
t
p
u
t
a
n
d
i
n
p
u
t
s
l
o
t
s
a
r
e
c
o
n
t
r
a
c
t
e
d
a
l
o
n
g
t
h
a
t
e
d
g
e
;
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
f
o
c
u
s
e
s
o
n
t
h
e
v
e
r
t
e
x
a
n
n
o
t
a
t
i
o
n
s
a
n
d
d
o
e
s
n
o
t
s
e
p
a
r
a
t
e
l
y
v
a
l
i
d
a
t
e
e
d
g
e
t
a
g
s
.
▪
When the second argument is
T
r
u
e
, a failing check prints one of four diagnostic message tags:
m
s
g
1
(vertices not annotated with tensors),
m
s
g
2
(indices not a duplicate-free list of
S
u
b
s
c
r
i
p
t
/
S
u
p
e
r
s
c
r
i
p
t
heads),
m
s
g
3
(tensor ranks and indices incompatible), and
m
s
g
4
(edges not tagged with indices). Both vertex-annotation checks are exercised in current builds;
m
s
g
1
and
m
s
g
4
are reserved for stricter checks added in future revisions.
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
is the graph-form sibling of
T
e
n
s
o
r
N
e
t
w
o
r
k
Q
: the latter tests
T
e
n
s
o
r
N
e
t
w
o
r
k
[
…
] expressions, while
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
tests the annotated
G
r
a
p
h
produced by
T
o
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
.
▪
Downstream functions including
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
D
a
t
a
,
T
e
n
s
o
r
N
e
t
w
o
r
k
I
n
d
i
c
e
s
,
T
e
n
s
o
r
N
e
t
w
o
r
k
T
e
n
s
o
r
s
, and
T
e
n
s
o
r
N
e
t
w
o
r
k
I
n
d
e
x
G
r
a
p
h
are guarded by
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
, so they remain unevaluated on an invalid graph rather than producing a wrong answer.
Examples
(
7
)
Basic Examples
(
1
)
Build a valid annotated tensor-network graph and test it:
I
n
[
1
]
:
=
S
e
e
d
R
a
n
d
o
m
[
4
2
]
;
g
=
T
o
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
R
a
n
d
o
m
T
e
n
s
o
r
N
e
t
w
o
r
k
[
"
M
P
S
"
[
4
,
2
,
2
]
]
;
I
n
[
2
]
:
=
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
g
]
O
u
t
[
2
]
=
T
r
u
e
A plain Graph carries no "Tensor" or "Index" annotations, so the predicate returns False:
I
n
[
3
]
:
=
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
G
r
a
p
h
[
{
1
2
,
2
3
}
]
]
O
u
t
[
3
]
=
F
a
l
s
e
Pass True as a second argument to print the first failing check on a malformed graph:
I
n
[
4
]
:
=
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
Q
[
G
r
a
p
h
[
{
1
2
}
]
,
T
r
u
e
]
O
u
t
[
4
]
=
F
a
l
s
e
S
c
o
p
e
(
4
)
A
p
p
l
i
c
a
t
i
o
n
s
(
1
)
P
r
o
p
e
r
t
i
e
s
&
R
e
l
a
t
i
o
n
s
(
1
)
S
e
e
A
l
s
o
T
o
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
G
r
a
p
h
D
a
t
a
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
Q
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
R
e
m
o
v
e
C
y
c
l
e
s
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
I
n
d
e
x
G
r
a
p
h
▪
G
r
a
p
h
▪
A
n
n
o
t
a
t
i
o
n
V
a
l
u
e
▪
G
r
a
p
h
Q
T
e
c
h
N
o
t
e
s
▪
B
u
i
l
d
i
n
g
T
e
n
s
o
r
N
e
t
w
o
r
k
s
R
e
l
a
t
e
d
G
u
i
d
e
s
▪
T
e
n
s
o
r
N
e
t
w
o
r
k
s
"
"