I am trying to find an the tensordot equivalent of the full reduction of two rank-N tensors of equal shape to a scalar via einsum. Both tensors are uniformly of order 3. I want to implement this with tensordot because I think it is easier to scale into higher dimensions. Here are the contractions with einsum up to 4D.
val_1D = np.einsum('i,i', A, B) #1D (aka dot-product)
val_2D = np.einsum('ij,ij', A, B) #2D
val_3D = np.einsum('ijk,ijk', A, B) #3D
val_4D = np.einsum('ijkl,ijkl', A, B) #4D
I need a way to make the N-th contraction without writing all of them out in the code as N can be quite large, and have multiple arrays to perform this on. As far as I understand tensordot this should be possible.