DeepLearning
EinsteinSummation
apply a generalized tensor contraction rule
Calling Sequence
Parameters
Options
Description
Details
Examples
Compatibility
EinsteinSummation(rule,t1,...,tn,opts)
rule
-
string; contraction rule for Tensor indices
t1,...,tn
zero or more Tensor objects to be passed to rule
opts
zero or more options as described below
name = string
The value of option name specifies an optional name for this Tensor to be displayed in output and when visualizing the dataflow graph.
The EinsteinSummation(rule,t1,...,tn,opts) command creates a Tensor in the active dataflow graph which is obtained by applying the generalized contraction rule rule to the Tensor arguments t1,...,tn.
This function is part of the DeepLearning package, so it can be used in the short form EinsteinSummation(..) only after executing the command with(DeepLearning). However, it can always be accessed through the long form of the command by using DeepLearning[EinsteinSummation](..).
The implementation of EinsteinSummation uses the tf.einsum command from the TensorFlow Python API. Consult the TensorFlow Python API documentation for tf.einsum for more information on Einstein summation and the syntax for rule specifically.
Examples of Einstein summation on vectors
with⁡DeepLearning:
a≔Constant⁡1.02342476022,0.34935719689,0.88659081013,0.59299726719,0.63322441838
a≔DeepLearning TensorShape: [5]Data Type: float[8]
b≔Constant⁡1.82052532615,−0.02883818599,1.09669226315,1.39986207979,1.62917836656
b≔DeepLearning TensorShape: [5]Data Type: float[8]
Dot product
EinsteinSummation⁡i,i->,a,b
DeepLearning TensorShape: []Data Type: float[8]
Outer product
EinsteinSummation⁡i,j->ij,a,b
DeepLearning TensorShape: [5, 5]Data Type: float[8]
Examples of Einstein summation on matrices
c≔Constant⁡1.73965,1.08139,0.65633|0.87144,0.60517,1.13247|1.32978,1.94794,1.14978
c≔DeepLearning TensorShape: [3, 3]Data Type: float[8]
d≔Constant⁡1.42797,0.43478,0.56673|1.32968,1.98237,1.29244|0.78380,1.03537,1.17197
d≔DeepLearning TensorShape: [3, 3]Data Type: float[8]
Matrix multiplication
res≔EinsteinSummation⁡ij,jk->ik,c,d
res≔DeepLearning TensorShape: [3, 3]Data Type: float[8]
Transpose
res≔EinsteinSummation⁡ij->ji,c
The DeepLearning[EinsteinSummation] command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
DeepLearning Overview
DifferentialGeometry,Tensor,ContractIndices
Download Help Document