I know we can calculate outer subtraction using broadcasting as given in

  
      stackoverflow.com
  
  
      
    
  

  Outer sum, etc. in pytorch 29



  python, optimization, pytorch, torch



  asked by
  
  
    iago-lito
  
  on 01:26PM - 12 Oct 18 UTC


  
  
    
    
  
  


But how can I do it for batches where first dimension is batch size and then we have second dimension to be the vectors for which we want to calculate outer subtraction between each vector in the first tensor with every other vector in the second tensor.