How to perform tensor production in Python/numpy?
<p>I have two numpy 2D-arrays and I want to perform this:</p>

<pre><code>a_ij * b_ik = c_ijk
</code></pre>

<p>How can I make it with numpy?</p>

<p><code>einsum</code> is tailor made for this task</p>

<pre><code>a_ij * b_ik = c_ijk

c = np.einsum('ij,ik-&gt;ijk', a, b)
</code></pre>

<p>===================</p>

<p>But as Divakar shows, no summation is implied, so plain multiplication works just as well, <code>a[...,None]*b[:,None,:]</code>.</p>

python numpy