Learn practical skills, build real-world projects, and advance your career
Created 3 years ago
PyTorch functions you must know to get started
PyTorch is an open source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing.It was developed to provide high flexibility and speed during implementing and building the Deep Learning Neural Network.
As any python library pytorch has its functions. Here are 5 Pytorch functions you should know:-
i)torch.tensor
ii)torch.arrange
iii)torch.cat
iv)torch.chunk
v)torch.hstack
Before we begin lets import Pytorch.
import torch
Function 1 : torch.tensor
One of the 1st and most important function to learn is the torch.tensor function. This function creates a tensor from the given data.
#Example 1 - working
t1 = torch.tensor(4.)
t1
tensor(4.)
The function took the input object in this case 4. and created a tensor i.e. tensor(4.)