Python: Numpy.dot / Numpy.tensordot For Multidimensional Arrays
I'm optimising my implementation of the back-propagation algorithm to train a neural network. One of the aspects I'm working on is performing the matrix operations on the set of da
Solution 1:
We can use np.einsum
-
c = np.einsum('ijk,ilm->ijl',a,b)
Since the last axes are singleton, you might be better off with sliced arrays -
c = np.einsum('ij,il->ijl',a[...,0],b[...,0])
With np.matmul/@-operator
-
c = a@b.swapaxes(1,2)
Post a Comment for "Python: Numpy.dot / Numpy.tensordot For Multidimensional Arrays"