Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
## Working same as np.dot()
np.matmul([[2,3],[3,4]],[[1,2],[5,6]])
#[Output]:
#array([[17, 22],
# [23, 30]])
## Here matmul will automatically brodcast if dimensiona are not same
np.matmul([[1, 0], [0, 1]],[1,2])
#[Output]:
#array([1, 2])
## It doesn't handle scalars.
np.matmul(2,3)
#[Output]:
#---------------------------------------------------------------------------
#ValueError Traceback (most recent call last)
#<ipython-input-6-fb0f0544aad2> in <module>()
# 1 ## It doesn't handle scalars.
#----> 2 np.matmul(2,3)
#ValueError: Scalar operands are not allowed, use '*' instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.