numpyで、下記の行列の掛け算ができないのですが、なぜですか?
数学上は、(4×3)行列*(3*2)行列の計算はできるはずです。
np.dot(a, b)ではできましたが、下記でできない理由が分かりません。
python
1a = np.random.randn(4, 3) # a.shape = (4, 3) 2b = np.random.randn(3, 2) # b.shape = (3, 2) 3c = a*b
下記がエラーの内容です。
python
1ValueError Traceback (most recent call last) 2<ipython-input-13-4bd2cd4ebeba> in <module>() 3 1 a = np.random.randn(4, 3) # a.shape = (4, 3) 4 2 b = np.random.randn(3, 2) # b.shape = (3, 2) 5----> 3 c = a*b 6 7ValueError: operands could not be broadcast together with shapes (4,3) (3,2)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。