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

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`
TensorNetwork
​
TensorNetwork
[{
A
1
,
A
2
,…},{
h
1
,
h
2
,…}]
creates a tensor network from tensors
A
i
and hyperedge index lists
h
i
; repeated indices in the
h
i
denote contractions.
​
​
TensorNetwork
[tensors,hyperedges,output]
fixes the order of free indices in the contracted result to
output
.
​
​
TensorNetwork
[tensors,inout]
uses Einstein-summation rule syntax.
​
​
TensorNetwork
[tensors,indices,perm]
with a
Cycles
permutation
perm
permutes the derived free indices.
​
​
TensorNetwork
[hyperedges]
builds a symbolic network with one
ArraySymbol
tensor per hyperedge.
​
​
TensorNetwork
[hyperedgesoutput]
builds a symbolic network with explicit output index list.
​
​
TensorNetwork
[hyperedgesoutput,dims]
with an
Association
dims
of indexdimension entries fixes the dimensions of symbolic tensors. •
​
​
TensorNetwork
[hyperedgesoutput,{
d
1
,
d
2
,…}]
with a positional list of dimensions for the union of indices.
​
​
TensorNetwork
[expr]
constructs a network from an
Inactive
TensorContract
over a
TensorProduct
. •
​
​
TensorNetwork
[
Transpose
[expr,perm]]
wraps a
Transpose
of an inactive contraction so the output index order follows
perm
. •
​
​
TensorNetwork
[graph]
reconstructs a network from a tensor-network
Graph
produced by
ToTensorNetworkGraph
.
​
Details and Options
▪
Repeated indices in the hyperedge lists denote contractions; indices appearing exactly once are free (output) indices.
▪
Hyperedge entries can be integers or symbols, but every entry of a single hyperedge list
h
must have length equal to the rank of the corresponding tensor.
▪
When the third argument is
Automatic
(the default), the free indices of the network are derived from the hyperedge structure in their order of first appearance.
▪
TensorNetwork
objects support property access via the syntax
tn["Property"]
; use
tn["Properties"]
to list every supported key.
▪
Use
TensorNetworkContract
to evaluate the network to a single tensor; the contraction path can be supplied explicitly or chosen by
GreedyContractionPath
or
OptimalContractionPath
.
▪
A network is binary when every index appears in at most two tensors; use
BinaryTensorNetwork
to convert a hyper-edge network (an index shared by three or more tensors) to its binary equivalent by inserting copy tensors.
BinaryTensorNetworkQ
tests for that condition.
▪
Output cells display a summary box (icon, tensor count, free-index count, binary/sparse flags, output dimension) generated by an upvalue on
MakeBoxes
; the icon is the network's hypergraph for binary networks with at most ten tensors and a placeholder graph otherwise.
​
Examples  
(35)
Basic Examples  
(2)
Create a tensor network representing matrix multiplication:
In[1]:=
tn=BlockRandomRandomSeed[1];
TensorNetwork
[RandomReal[1,#]&/@{{2,3},{3,2,3},{3,4}},{{i,j},{j,k,l},{l,m}}]
Out[1]=
TensorNetwork
Tensors: 3
Binary: Yes
Free indices: 3
Sparse: No
Output dimension: 16
​

Visualize the tensor network structure:
In[2]:=
tn["Hypergraph"]
Out[2]=
Contract the network to get the result:
In[3]:=
TensorNetworkContract
[tn]
Out[3]=
{{{0.450216,0.244854,1.07489,1.38969},{0.549743,0.329563,1.08865,1.23591}},{{0.568642,0.316769,1.33932,1.76742},{0.611233,0.371568,1.17524,1.30506}}}
​
Define a collection of randomly-generated complex tensors with some given dimensions:
In[1]:=
tensors=SparseArray[RandomComplex[{-1-I,1+I},#]]&/@{{3,4},{3,3,4},{3,3,4},{3,4}};
Given tensors, define the tensor network by feeding indices:
In[2]:=
tn=
TensorNetwork
[tensors,{{1,5},{1,2,6},{2,3,7},{3,8}}]
Out[2]=
TensorNetwork
Tensors: 4
Binary: Yes
Free indices: 4
Sparse: Yes
Output dimension: 256
​

Visualize its hypergraph:
In[3]:=
tn["Hypergraph"]
Out[3]=
Contract the tensor network:
In[4]:=
TensorNetworkContract
[tn]
Out[4]=
SparseArray
Specified elements: 256
Dimensions: {4,4,4,4}

Scope  
(9)

Applications  
(3)

Properties & Relations  
(20)

Neat Examples  
(1)

SeeAlso
TensorNetworkContract
 
▪
TensorNetworkQ
 
▪
TensorNetworkData
 
▪
RandomTensorNetwork
 
▪
EinsteinSummation
 
▪
SparseTensorNetwork
 
▪
BinaryTensorNetwork
 
▪
ToTensorNetworkGraph
 
▪
TensorNetworkAdd
 
▪
TensorNetworkDelete
 
▪
TensorContract
 
▪
TensorProduct
 
▪
Inactive
TechNotes
▪
TensorNetworks Overview
​​
Building Tensor Networks
​​
Contraction Paths and Execution
RelatedGuides
▪
TensorNetworks
RelatedLinks
▪
Tensor Network on Wikipedia
""

© 2026 Wolfram. All rights reserved.

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