I want to use dot product between the leading and trailing axes of arrays with unspecified dimensions. einsum doesn't seem to accommodate this use case. User error?
With prnd=np.random.RandomState(),
np.einsum('...i,i...', prnd.rand(5,2), prnd.rand(2,3))
Traceback (most recent call last):
File "/tmp/ipykernel_1106807/647899105.py", line 1, in <module>
np.einsum('...i,i...', prnd.rand(5,2), prnd.rand(2,3))
File "<__array_function__ internals>", line 5, in einsum
File "/home/elliot/anaconda3/envs/current/lib/python3.9/site-packages/numpy/core/einsumfunc.py", line 1359, in einsum
return c_einsum(*operands, **kwargs)
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (5,2)->(5,2) (2,3)->(3,2)
should be the same as...
np.einsum('ai,ib', prnd.rand(5,2), prnd.rand(2,3)).shape
Out[69]: (5, 3)
np.__version__
Out[70]: '1.21.4'