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

Amazing PyTorch functions you need to know!

Here is a list of 5 PyTorch functions

An short introduction about PyTorch and about the chosen functions.

  • torch.cos(input, out=None)
  • torch.reciprocal(input, out=None)
  • torch.cat(tensors, dim=0, out=None) → Tensor
  • torch.linspace(start, end, steps=100, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)
  • torch.full(size, fill_value, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)
# Import torch and other required modules
import torch

torch.cos(input, out=None)

This function takes an input and outputs the cosine of that function.
# Working
torch.cos(torch.randn(1))

It is generating a random integer using randn() function and gives output of cosine of that input