Learn practical skills, build real-world projects, and advance your career

Pytorch zero to gan : First Assignment

PyTorch is an open source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab.

The choosen functions are as follows:-

  • torch.zeros()
  • torch.arange()
  • torch.linspace()
  • torch.eye()
  • torch.cat()
# Import torch and other required modules
import torch

Function 1 - torch.zeros()

Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.

# Example 1 
torch.zeros(10,3)
tensor([[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])

Create a matrix of 10 rows and 3 columns , filled with zeros