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

Learning PyTorch

Homework 1

I want to use PyTorch to gain experience in Data Science and Machine Learning. Functions below are helpful to work with data in tensors.

  • torch.rand
  • torch.dtype
  • torch.Size
  • torch.sum
  • torch.grad
# Import torch and other required modules
import torch

Function 1 - torch.rand

Function returns a tensor of given dimetions filled with random numbers between 0 and 1.

# Example 1 - working 
a = torch.rand(3,3)
a
tensor([[0.5381, 0.8339, 0.5038],
        [0.6175, 0.4230, 0.5213],
        [0.7420, 0.3825, 0.1029]])

Tensor in size 3x3 was created.