機械学習に詳しくなりたいブログ

機械学習や数学について勉強した内容を中心に書きます。100%趣味です。記事は数学的に厳密でなかったり誤りを含んでいるかもしれません。ご指摘頂ければ幸いです。

行列の内積

うっかり行列の積と混同していると大変なことになる。

行列の内積は、対応する全ての要素の積の和です。


\begin{eqnarray*}
  \mathbf A \cdot \mathbf B &=& \left(
    \begin{array}{cccc}
      a_{11} & a_{12} & \ldots & a_{1n} \\
      a_{21} & a_{22} & \ldots & a_{2n} \\
      \vdots & \vdots & \ddots & \vdots \\
      a_{m1} & a_{m2} & \ldots & a_{mn}
    \end{array}
  \right) \cdot
   \left(
    \begin{array}{cccc}
      b_{11} & b_{12} & \ldots & b_{1n} \\
      b_{21} & b_{22} & \ldots & b_{2n} \\
      \vdots & \vdots & \ddots & \vdots \\
      b_{m1} & b_{m2} & \ldots & b_{mn}
    \end{array}
  \right) \tag{1} \\
\displaystyle &=& \sum_{i=1}^{m} \sum_{j=1}^n a_{ij}b_{ij} \tag{2}
\end{eqnarray*}

定義から明らかなように


\mathbf A \cdot \mathbf B = \mathbf B \cdot \mathbf A \tag{3}

が成り立ちます。