Python numpy - 矩阵

  • 求逆矩阵
用numpy的linalg库

先判断矩阵是否可逆,再运算

    if np.linalg.det(xTx) == 0:
        print("This matrix is singular, cannot be inversed!")
    ws = xTx.I * (xMat.T * yMat)

是否可以用try...except...else...finally来完成?不知道抛出的except名字

  • flatten
以下引用自:http://blog.csdn.net/qq_18433441/article/details/54916991

有的时候发现一个2维的矩阵被一层层套在括号里,形式非常难懂,可以用flatten.A[0]把它解救出来...还挺有用的!

猜你喜欢

转载自blog.csdn.net/maomaona/article/details/79599399
今日推荐