擅长:python、mysql、java
<blockquote>
<p>I thought that this is matrix multiplication</p>
</blockquote>
<p>除非使用<code>matrix</code>对象或<code>dot</code>方法/函数,否则它不是。这是元素乘法,对于不匹配的维度,有一些称为<a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html" rel="nofollow">broadcasting</a>的额外处理。如果你想要矩阵乘法,用</p>
<pre><code>numpy.dot(A, B)
</code></pre>
<p>您也可以使用<code>matrix</code>对象来代替<code>ndarray</code>s,但是它们导致的不一致性可能会让人讨厌。你需要知道如果给定一个矩阵,什么操作会返回一个矩阵,什么操作总是返回一个数组,<code>A[x][y]</code>将不起作用,还有更多的小问题会把你搞砸。在</p>