I have two n
-by-k
-by-3
arrays a
and b
, e.g.,
import numpy as np
a = np.array([
[
You are loosing the third axis on those two 3D
input arrays with that sum-reduction, while keeping the first two axes aligned. Thus, with np.einsum, we would have the first two strings identical alongwith the third string being identical too, but would be skipped in the output string notation signalling we are reducing along that axis for both the inputs. Thus, the solution would be -
np.einsum('ijk,ijk->ij',a,b)