Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created December 12, 2019 09:28
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/79d938591a3ddf6d2234dc54c441082c to your computer and use it in GitHub Desktop.
Save nithyadurai87/79d938591a3ddf6d2234dc54c441082c to your computer and use it in GitHub Desktop.
import torch
x1 = torch.Tensor()
print (x1)
x2 = torch.Tensor([1,2,3])
print (x2)
print (x2.size())
print (x2.dtype)
x3 = torch.tensor([1,2,3])
x4 = torch.as_tensor([1,2,3])
print (x3)
print (x4)
print (x3+x4)
#print (x2+x3)
print (x4.dtype)
print (x4.device)
print (x4.layout)
print (torch.eye(2))
print (torch.zeros(2,2))
print (torch.ones(2,2))
print (torch.rand(2))
print (torch.rand(2,3))
print (torch.rand(2,3,4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment