Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
# Assignment 1
### Pytorch Functions
An short introduction about PyTorch and about the chosen functions.
- Function 1 - torch.from_numpy
- Function 2 - torch.rand
- Function 3 - torch.tensor
- Function 4 - torch.linspace
- Function 5 - torch.reshape
# Import torch and other required modules
import torch
import numpy as np
Function 1 - torch.from_numpy
pytorch can convert a numpy array to pytorch tensor
# Example 1 - working
torch.from_numpy(np.array([[3,2,1],[3,4,5],[3,33,333]]))
tensor([[ 3, 2, 1],
[ 3, 4, 5],
[ 3, 33, 333]])
pytorch tensors can be created directly from numpy arrays