Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created December 12, 2019 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nithyadurai87/8109fea71fd03258a494d4b8ee727a9a to your computer and use it in GitHub Desktop.
Save nithyadurai87/8109fea71fd03258a494d4b8ee727a9a to your computer and use it in GitHub Desktop.
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