title: Broadcast failure: how to dictate the axes of broadcasting?
body: <p>I have a tensor of size (1000, 30, 16, 16). I'm doing experiments on how to normalize it. I'm trying to normalize across cases, and may be frequency axis etc.</p>
  
  <p>The following works:</p>
  
  <pre><code>a = np.random.rand(1000, 30, 16, 16)
  a - a.mean(axis=(0, )) #==&gt; it works
  a - a.mean(axis=(0, 1)) #==&gt; successful broadcast
  a - a.mean(axis=(0, 1, 2)) #==&gt; works well
  a - a.mean(axis=(0, 1, 2, 3)) #==&gt; succesful broadcast of scalar mean to all a values
  
  
  #Those however fail:
  a - a.mean(axis=(2, 3)) 
  #OR:
  a - a.mean(axis=(0, 2, 3))
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>ValueError: operands could not be broadcast together with shapes (1000, 30, 16, 16) (30,)</p>
  </blockquote>
  
  <p>It seems that it succesfully completes the missing axes in simple cases like
  (30, 16, 16)</p>
  
  <p>(16, 16)</p>
  
  <p>(16,)</p>
  
  <p>(1,)</p>
  
  <p>But fails when the missing axes are to the right rather than left, eg:
  (1000, 30) and it cannot broadcast it to (1000, 30, 16, 16).</p>
  
  <p>To be specific with my question, how can I dictate how broadcasting is being done?
  For instance, I have (30,) and I want to broadcast it to (1000, 30, 16, 16)</p>
  
  <p>It throws an error as it fails to broadcast. I have a <em>hacky</em> solution, which permuting the axes and making (30,) comes last so that broadcasting works, but I'm wondering if there's a way to dictate how broadcasting should be done. And furthermore, why is't this being done automatically?</p>