This discussion may be helpful.

  
    
    
    RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 224] at entry 0 and [3, 224, 336] at entry 3 vision
  
  
    So you mean to say, even if the transforms.Resize() is included in transforms.Compose(), there is still an error of size mismatch ?
  


Usually, in such situations some sort of padding has to be introduced for each batch so all elements match in size. This can be achieved by defining your own collate_fn that is then passed to DataLoader as an argument.