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

Multiplication of tensors in pytorch

Vector and Matrix operations using pytorch

PyTorch is an open source machine learning framework which enables it's users to build software by levaraging python's ease of use and having the freedom to build stuff from scratch.

  • torch.dot()
  • torch.ger()
  • torch.mul()
  • torch.matmul()
  • torch.chain_matmul()
# Import torch and other required modules
import torch

Function 1 - torch.dot()

Computes inner(dot) product of two 1D tensors(vectors)

# Example 1 - working
a = torch.tensor([1., 2])
b = torch.tensor([5., 6])
a, b
(tensor([1., 2.]), tensor([5., 6.]))
torch.dot(a, b)
tensor(17.)