Created
December 12, 2019 09:29
-
-
Save nithyadurai87/8109fea71fd03258a494d4b8ee727a9a to your computer and use it in GitHub Desktop.
This file contains 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
import torch | |
x = torch.Tensor([[110,120,90],[160,20,60]]) | |
print (x.topk(k = 1, dim = 1)) | |
print (x.topk(k = 2, dim = 1)) | |
print (x.topk(k = 1, dim = 0)) | |
print (x.topk(k = 2, dim = 0)) | |
print (torch.Tensor([110]).item()) | |
print (x.mul_(2)) | |
y = x.numpy() | |
z = torch.from_numpy(y) | |
print (type(y)) | |
print (type(z)) | |
a = x.view(1,-1) | |
print(a) | |
print(a.size()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment