title: PyTorch Broadcasting Failing. "Rules" Followed
body: <p>I have a few PyTorch examples that confuse me and am hoping to clear it up.</p>
  
  <p>Firstly, as per the PyTorch page, I would expect these example to work as do their numpy equivalents namely <a href="https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html" rel="nofollow noreferrer">these</a>. The first example is very intuitive. These are compatible for broadcasting:</p>
  
  <pre><code>Image  (3d array): 256 x 256 x 3
  Scale  (1d array):             3
  Result (3d array): 256 x 256 x 3
  </code></pre>
  
  <p>Take for instance these:</p>
  
  <pre><code>torch.Tensor([[1,2,3]])/torch.Tensor([1,2,3])
  Out[5]: 
  
   1  1  1
  [torch.FloatTensor of size 1x3]
  torch.Tensor([[1,2,3]])/torch.Tensor([1,2,3])
  Out[6]: 
  
    1  1  1
  [torch.FloatTensor of size 1x3]
  
  torch.Tensor([[[1,2,3]]])/torch.Tensor([1,2,3])
  Out[7]: 
  
  (0 ,.,.) = 
    1  1  1
  [torch.FloatTensor of size 1x1x3]
  </code></pre>
  
  <p>However, this is the result of the numpy example:</p>
  
  <pre><code>torch.randn(256,256,3)/torch.Tensor([1,2,3])
  Traceback (most recent call last):
  
    File "&lt;ipython-input-12-4c328d453e24&gt;", line 1, in &lt;module&gt;
      torch.randn(256,256,3)/torch.Tensor([1,2,3])
  
    File "/home/nick/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 313, in __div__
      return self.div(other)
  
  RuntimeError: inconsistent tensor size at /opt/conda/conda-bld/pytorch_1501971235237/work/pytorch-0.1.12/torch/lib/TH/generic/THTensorMath.c:873
  </code></pre>
  
  <p><a href="http://pytorch.org/docs/master/notes/broadcasting.html" rel="nofollow noreferrer">Here is an excerpt which says this ought to work:</a></p>
  
  <blockquote>
    <p>Two tensors are “broadcastable” if the following rules hold:</p>
    
    <ol>
    <li>Each tensor has at least one dimension.</li>
    <li><strong>When iterating over the dimension sizes, starting at the trailing dimension, the dimension sizes must either be equal</strong>, one of them is 1, or one of them does not exist.</li>
    </ol>
  </blockquote>
  
  <p>If one converts the tensors to numpy arrays the arithmetic works as expected.</p>
  
  <p>What's going wrong? Have I misinterpreted the docs and if so what syntax results in the same results?</p>