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

Some of basic PyTorch’s functions

torch

An short introduction about PyTorch and about the chosen functions.

  • function 1 - torch.rand()
  • function 2 - torch.arange()
  • function 3 - torch.reshape()
  • function 4 - torch.matmul()
  • function 5 - torch.zeros()
# Import torch and other required modules
import torch

Function 1 - torch.rand()

Add some explanations

# Example 1 - working (change this)
torch.rand(3,4,2)
tensor([[[0.6065, 0.5806],
         [0.0071, 0.8346],
         [0.5620, 0.6766],
         [0.1351, 0.8016]],

        [[0.5982, 0.0475],
         [0.2820, 0.1375],
         [0.4561, 0.0439],
         [0.2330, 0.0366]],

        [[0.1402, 0.5983],
         [0.3887, 0.3072],
         [0.8634, 0.9332],
         [0.5336, 0.5947]]])

Generate Random Number
Number Passing as linear in rand function