user153245
user153245

Reputation: 287

Why the installed numpy in my system does not have matmul?

I have installed numpy as following in ubuntu 14.04, but as is indicated in the sample code using matmul leads to error.

sudo apt-get install python3-numpy

$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.8.2'
>>> a = [[1, 0], [0, 1]]
>>> b = [[4, 1], [2, 2]]
>>> np.matmul(a, b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'matmul'
>>> 

What is my fault?
Thanks.

Upvotes: 2

Views: 5665

Answers (2)

PxBartonx
PxBartonx

Reputation: 1

I was getting a similar error when using the np.linalg.matmul and np.linalg.dot syntax, resulting in: AttributeError: module 'numpy.linalg' has no attribute 'matmul'

I dropped the ".linalg" so in my situation np.dot and np.matmul would be the correct syntax, but np.linalg.dot and np.linalg.matmul will raise an error. This makes me wonder if dot and matmul are actually in the linalg module, as other functions such as np.linalg.inv and np.linalg.eig definitely require the np.linalg syntax

Upvotes: 0

DeepSpace
DeepSpace

Reputation: 81654

np.matmul was added in numpy 1.10.0, as per the docs:

New in version 1.10.0

Upvotes: 7

Related Questions