numpy 点积 ValueError: shapes (3,2) and (3,) not aligned: 2 (dim 1) != 3 (dim 0)
numpy矩阵点积时,经常遇到这样的错误:ValueError:shapes(3,2)and(3,)notaligned:2(dim1)!=3(dim0)这表示点积左边的矩阵维度(dim)是3*2的,而右边的数组有3个元素,2!=3,于是报错。这时可以将右边的数组移到点积的左边,于是变成了3个元素的数组和3*2的矩阵的点积,此时3=3,便不会报错了。数组和矩阵做点积时,需要相邻的数字相等,否则就会