What is the difference between
import numpy as np
np.dot(a,b)
and
import numpy as np
np.inner(a,b)
all examples I tried returned the same result. Wikipedia has the same article for both?! In the description of inner() it says, that its behavior is different in higher dimensions, but I couldn’t produce any different output. Which one should I use?
numpy.dot:numpy.inner:(Emphasis mine.)
As an example, consider this example with 2D arrays:
Thus, the one you should use is the one that gives the correct behaviour for your application.
Performance testing
(Note that I am testing only the 1D case, since that is the only situation where
.dotand.innergive the same result.)So maybe
.inneris faster, but my machine is fairly loaded at the moment, so the timings are not consistent nor are they necessarily very accurate.