Python - 行列の掛け算
Numpyを使います。np.dot(A, B)で簡単にできます。 例えば、A([1, 2, 3], [4, 5, 6])と、B([7], [8], [9])を掛けます。
import numpy as np
A = np.array([[1, 2, 3], [4, 5, 6]])B = np.array([[7], [8], [9]])print(np.dot(A, B))下記が出力されます。
[[ 50] [122]][mathjax] $$\begin{pmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{pmatrix} \begin{pmatrix} 7 \ 8 \ 9 \end{pmatrix}$$