-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Update: TensorOperations does not have big advantage over NumPy for large tensors.
In NumPy, we have a handy feature in np.tensordot, as illustrated below:
import numpy as np
ts1 = np.random.rand(2,3,4,5)
ts2 = np.random.rand(5,4,3,2)
# contract the last index of ts1 and first index of ts2
ts_ctrct = np.tensordot(ts1, ts2, axes=((3), (0)))
print(np.shape(ts_ctrct))
The axes option can quickly tell the program which indices should be contracted. However, the equivalent function tensorcontract is hard to use when the number of indices is large. For example,
using TensorOperations
using Random
ts1 = rand(2,3,4,5)
ts2 = rand(5,4,3,2)
@tensor ts_ctrct = tensorcontract(ts1, (1,2,3,4), ts2, (4,5,6,7))
println(size(ts_ctrct))
I have to manually write down (1,2,3,4...). Thus I would like to suggest to use the axes option to replace the index currently widely used in TensorOperations.
Metadata
Metadata
Assignees
Labels
No labels