Skip to content

Instantly share code, notes, and snippets.

@vaibkumr
Created October 11, 2019 16:43
Show Gist options
  • Save vaibkumr/d9eb58703537241ec80f11ad3ab479b3 to your computer and use it in GitHub Desktop.
Save vaibkumr/d9eb58703537241ec80f11ad3ab479b3 to your computer and use it in GitHub Desktop.
import torch
# The following will produce no error as the dimensions match
batch1= torch.zeros(64, 3, 100, 100, names=('N', 'C', 'H', 'W'))
batch2 = torch.zeros(64, 3, 100, 100, names=('N', 'C', 'H', 'W'))
batch3 = batch1 + batch2
# The following will produce an error as the dimensions don't match
batch1= torch.zeros(64, 3, 100, 100, names=('N', 'C', 'H', 'W'))
batch2 = torch.zeros(64, 3, 100, 100, names=('N', 'C', 'W', 'H'))
batch3 = batch1 + batch2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment