Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Pytorch zero to gan : First Assignment
Functions
The choosen functions are:
- torch.ones()
- torch.square()
- torch.where()
- torch.randint()
- torch.clamp()
# Import torch and other required modules
import torch
Function 1 - torch.ones()
Returns a tensor filled with the value 1, with the shape defined by the variable argument size.
# Example 1 -
torch.ones(3,3)
tensor([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]])
Create a matrix of 3 rows and 3 columns , filled with ones