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
  • Index conventions and contraction path
  • 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
  • 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
  • $TensorNetworkContractionMethods
Wolfram`TensorNetworks`
TensorNetworkContraction
​
TensorNetworkContraction
[tn]
returns an inactive contraction expression for the tensor network using an auto-selected path •
​
​
TensorNetworkContraction
[tn,path]
uses the explicit canonical contraction path •
​
​
TensorNetworkContraction
[tn,treePath]
uses a tree-structured contraction path •
​
​
TensorNetworkContraction
[tn,"Greedy"]
auto-computes a greedy contraction path •
​
​
TensorNetworkContraction
[tn,method]
uses method-string "Optimal", "flops", "max", "size", "write", "combo", or "limit" •
​
​
TensorNetworkContraction
[graph]
operates on a tensor-network Graph •
​
​
TensorNetworkContraction
[data]
accepts the low-level Association of network data
​
Details and Options
▪
By default
TensorNetworkContraction
returns an
Inactive
expression tree (
"Inactive"True
) that you can inspect, transform, or pass to
ContractionTree
.
▪
Setting
"Inactive"False
evaluates the tree and returns the numerical tensor; this is the path
TensorNetworkContract
takes.
▪
ActivateTensors
collapses a returned tree into a numerical tensor; this is useful when the tree has already been inspected and only the value is needed.
▪
The
Method
option selects one of five binary-contraction engines: "ArrayDot" (default), "ArrayDotTranspose", "Dot", "TensorContract", and "TableSum". All engines produce numerically identical results after activation; they differ only in the internal representation of the tree. The full list is in
$TensorNetworkContractionMethods
.
▪
For a single-tensor network (no contraction indices),
TensorNetworkContraction
returns the tensor directly via the
EinsteinSummation
fallback path.
▪
A
path
is a list of integer pairs
{{i,j},…}
in opt_einsum convention; a
treePath
is the tree-structured form produced by
PathToTreePath
.
▪
The following options can be given:
Method
"ArrayDot"
binary-contraction engine, one of $TensorNetworkContractionMethods.
"Inactive"
True
when False, evaluates the tree (equivalent to TensorNetworkContract).
"TransposeFunction"
Transpose
transpose primitive used for the final permutation step.
​
Examples  
(17)
Basic Examples  
(1)
Construct a small two-tensor network used in the examples below:
In[1]:=
tn=
TensorNetwork
[{{{0.5,-0.2,0.3},{0.1,0.8,-0.4}},{{0.6,0.4,-0.1,0.2},{-0.3,0.5,0.7,-0.2},{0.1,-0.4,0.3,0.5}}},{{i,j},{j,k}}]
Out[1]=
TensorNetwork
Tensors: 2
Binary: Yes
Free indices: 2
Sparse: No
Output dimension: 8
​

Return the default inactive contraction expression:
In[2]:=
TensorNetworkContraction
[tn]
Out[2]=
TensorContract[{{0.5,-0.2,0.3},{0.1,0.8,-0.4}}{{0.6,0.4,-0.1,0.2},{-0.3,0.5,0.7,-0.2},{0.1,-0.4,0.3,0.5}},{{2,3}}]
Evaluate the tree with ActivateTensors:
In[3]:=
ActivateTensors

TensorNetworkContraction
[tn]
Out[3]=
{{0.39,-0.02,-0.1,0.29},{-0.22,0.6,0.43,-0.34}}
The option "Inactive"  False evaluates the tree on the fly:
In[4]:=
TensorNetworkContraction
[tn,"Inactive"False]
Out[4]=
{{0.39,-0.02,-0.1,0.29},{-0.22,0.6,0.43,-0.34}}
Scope  
(9)

Options  
(3)

Applications  
(1)

Properties & Relations  
(1)

Possible Issues  
(2)

SeeAlso
TensorNetworkContract
 
▪
ContractionTree
 
▪
$TensorNetworkContractionMethods
 
▪
OptimalContractionPath
 
▪
GreedyContractionPath
 
▪
BinaryTensorNetwork
 
▪
TensorNetwork
 
▪
Inactive
 
▪
TensorContract
TechNotes
▪
Contraction Paths and Execution
RelatedGuides
▪
TensorNetworks
""

© 2026 Wolfram. All rights reserved.

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