DeepLearning - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : DeepLearning Package : Tensors : Managing Tensors : DeepLearning/EinsteinSummation

DeepLearning

  

EinsteinSummation

  

apply a generalized tensor contraction rule

 

Calling Sequence

Parameters

Options

Description

Details

Examples

Compatibility

Calling Sequence

EinsteinSummation(rule,t1,...,tn,opts)

Parameters

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

Options

• 

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.

Description

• 

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](..).

Details

• 

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

Examples of Einstein summation on vectors

withDeepLearning:

aConstant1.02342476022,0.34935719689,0.88659081013,0.59299726719,0.63322441838

aDeepLearning TensorName: Const:0Shape: [5]Data Type: float[8]

(1)

bConstant1.82052532615,0.02883818599,1.09669226315,1.39986207979,1.62917836656

bDeepLearning TensorName: Const_1:0Shape: [5]Data Type: float[8]

(2)

Dot product

resEinsteinSummationi,i->,a,b

resDeepLearning TensorName: einsum/Reshape_2:0Shape: []Data Type: float[8]

(3)

valueres

4.68716306097872

(4)

Outer product

resEinsteinSummationi,j->ij,a,b

resDeepLearning TensorName: einsum_1/Mul:0Shape: [5, 5]Data Type: float[8]

(5)

valueres

1.86317069538950−0.02951371358199551.122382016449421.432653513350151.667341479152280.636013624811017−0.01007482782085890.3831373349050340.4890518922280400.5691651873752301.61406102377351−0.02556767067955370.9723172820494621.241104855391281.444414567854701.07956654325713−0.01710096548278690.6503355149963660.8301143877583800.9660983191351481.15280109079739−0.01826104355065200.6944523204750050.8864268512872401.03163552360223

(6)

Examples of Einstein summation on matrices

cConstant1.73965,1.08139,0.65633|0.87144,0.60517,1.13247|1.32978,1.94794,1.14978

cDeepLearning TensorName: Const_2:0Shape: [3, 3]Data Type: float[8]

(7)

dConstant1.42797,0.43478,0.56673|1.32968,1.98237,1.29244|0.78380,1.03537,1.17197

dDeepLearning TensorName: Const_3:0Shape: [3, 3]Data Type: float[8]

(8)

Matrix multiplication

resEinsteinSummationij,jk->ik,c,d

resDeepLearning TensorName: einsum_2/MatMul:0Shape: [3, 3]Data Type: float[8]

(9)

valueres

3.616678913100005.759355188000003.824262769400002.911264327100005.155169081700003.757095586700002.081209676100004.603705091500003.03446458450000

(10)

Transpose

resEinsteinSummationij->ji,c

resDeepLearning TensorName: einsum_3/transpose:0Shape: [3, 3]Data Type: float[8]

(11)

valueres

1.739650000000001.081390000000000.6563300000000000.8714400000000000.6051700000000001.132470000000001.329780000000001.947940000000001.14978000000000

(12)

Compatibility

• 

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