Skip to content

Instantly share code, notes, and snippets.

@vaibkumr
Created October 11, 2019 16:51
Show Gist options
  • Save vaibkumr/bb839e27adcc6cc7636ec37000930d1b to your computer and use it in GitHub Desktop.
Save vaibkumr/bb839e27adcc6cc7636ec37000930d1b to your computer and use it in GitHub Desktop.
import torch
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 = torch.zeros(64, 3, 100, 100)
batch4 = torch.zeros(64, 3, 100, 100)
batch5 = torch.zeros(64, 3, 100, 100, names=('N', 'C', 'W', 'H'))
#Name tuple strings are equal so name matches
res1 = batch1 + batch2
#Name of one of the inputs (batch3) is None so matches
res2 = batch1 + batch3
#Name of both the inputs are None so matches
res2 = batch3 + batch4
#Name tuple strings are not equal so no name match and error
res3 = batch1 + batch5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment