Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Title Here
Basic Functions on Tensors
An short introduction about PyTorch and about the chosen functions.
- torch.tensor
- torch.normal
- torch.rand
- torch.tensor.apply()
- torch.tensor.dot()
# Import torch and other required modules
import torch
Function 1 - torch.tensor
2x2 tensor with only prime numbers. It is also a differentiable tensor. At the end I also print it out in "console"
# Example 1 - working (change this)
q = torch.tensor([[1, 5], [7, 11]], dtype=torch.float64, requires_grad=True)
print(q)
print(q.dtype)
tensor([[ 1., 5.],
[ 7., 11.]], dtype=torch.float64, requires_grad=True)
torch.float64
This is pretty much the same example but i changed the type of tensor, i mean, instead of a float it's a integer