Last active
October 11, 2019 18:23
-
-
Save vaibkumr/2292ac3ef7196fd5b2138846e0c943dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################### | |
# Before PyTorch v1.3 | |
##################### | |
import torch | |
batch = torch.zeros(2, 3, 2, 2, 2, 2, 2, 2, 2, 2) | |
print(batch.shape) | |
batch = batch.permute([0, 2, 1, 3, 4, 5, 6, 7, 8, 9]) | |
print(batch.shape) | |
##################### | |
# After PyTorch v1.3 | |
##################### | |
import torch | |
alphas = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] | |
batch = torch.zeros(2, 3, 2, 2, 2, 2, 2, 2, 2, 2, names=alphas) | |
print(batch.shape) | |
batch = batch.align_to('a', 'c', 'b', ...) | |
print(batch.shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment