Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
PyTorch Useful Functions
Implementing PyTorch functions
PyTorch is an open source machine learning library based on the Torch library. It is used in applications such as computer vision and NLP. The five most useful functions are the following:
- torch.randn
- torch.add
- torch.mean
- torch.view
- torch.cat
# Import torch and other required modules
import torch
Function 1 - torch.randn
Generates normally distributed random numbers.
# Example 1 - working (change this)
t1 = torch.randn(5)
t1
tensor([-1.4884, 0.8141, 0.5104, -0.4515, 0.1181])
Generates tensor of size 5 containing normally distributed random numbers.