二つの行ベクトルa,bから、aを列ベクトルにしたものとbを行ベクトルにしたものの内積を取りたいです。
c = a(T)b
を行いたいです。
そのため以下の処理を行ったのですがエラーが出ました。
Python
1import numpy as np 2 3a = np.asarray([1,2,3]) 4b = np.asarray([1,2,3,4]) 5 6print(np.dot(a.T,b.T)) 7
error
1Traceback (most recent call last): 2 File "/Users/name/Documents/python_code/test.py", line 6, in <module> 3 print(np.dot(a.T,b.T)) 4ValueError: shapes (3,) and (4,) not aligned: 3 (dim 0) != 4 (dim 0) 5>>>
解決策を教えていただければ嬉しいです。
よろしくお願いします
回答2件
あなたの回答
tips
プレビュー