python - Compute numpy.inner() over first (instead of last) axis -



python - Compute numpy.inner() over first (instead of last) axis -

i'm trying create function numpy.inner, sums on first axis of both arrays instead of lastly axis. i'm using tensordot rollaxis:

def inner1(a, b): homecoming numpy.tensordot(numpy.rollaxis(a, 0, len(a.shape)), b, 1)

but i'm wondering: there improve way? perhaps 1 doesn't require me roll axes?

i sense einsum should create possible, i'm not sure how utilize here. seems require me hard-code dimensionality of a , b when specify subscripts string, can't here because there no particular requirement on input dimensionality.

(note: am aware there performance implications summing on first axis instead of last, i'm ignoring them here.)

i think want np.tensordot(a, b, (0, 0)).

python arrays numpy linear-algebra inner-product

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -