just in case you were wondering about the difference:

  
      stackoverflow.com
  
  
      
    
  

  What's the difference between torch.stack() and torch.cat() functions? 2.2k



  python, machine-learning, pytorch



  
  answered by
  
    Jatentaki
  
  on 11:31AM - 22 Jan 19 UTC


  
  
    
    
  
  



stack

Concatenates sequence of tensors along a new dimension.

cat

Concatenates the given sequence of seq tensors in the given dimension.

So if A and B are of shape (3, 4), torch.cat([A, B], dim=0) will be of shape (6, 4) and torch.stack([A, B], dim=0) will be of shape (2, 3, 4).