Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
PyTorch - An easy Library mainly for Machine/Deep Learning Application
Operations using PyTorch
PyTorch is an open source Machine Learning library based on Torch library which can be used in many Machine Learning or Deep Learning application like Computer Vision , NLP (Natural Language Processing) etc. which is primarily built by Facebook.
Here are most frequently used function in PyTorch .
- Function 1 - torch.tensor()
- Function 2 - torch.add()
- Function 3 - torch.matmul()
- Function 4 - torch.reshape()
- Function 5 - torch.median()
- Function 6 - torch.max()
# Import torch and other required modules
import torch
import numpy as np
Function 1 - torch.tensor ()
A torch.Tensor is a multi-dimensional matrix containing elements/numbers.
Since tensor forms the basis for building neural network in PyTorch , its better to learn about tensors before moving forawrd to learn other operations available in PyTorch.
# Example 1 - working
torch.tensor([5,7])
tensor([5, 7])
Here we are creating tensor from the Python list using torch.tensor() constructor .