AttributeError: 'numpy.ndarray' object has no attribute 'I'

>>>a = np.array([[3,4],[1,2]])
>>> a
array([[3, 4],
       [1, 2]])
>>> invA = np.linalg.inv(a)
>>> invA
array([[ 1. , -2. ],
       [-0.5,  1.5]])
>>> a.I
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'numpy.ndarray' object has no attribute 'I'

解决方法:

>>> a = np.mat([[3,4],[1,2]])
>>> a.I
matrix([[ 1. , -2. ],
        [-0.5,  1.5]])

你可能感兴趣的:(python使用)