Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Pytorch Zero to GAN : Basic tensors
Pytorch is an open sourced deep learning library for python, it is developed by Facebook research lab. This notebook covers the exploration of few pytroch tensor functions
Choosen pytorch tensor functions
# Import torch and other required modules
import torch
import numpy as np
Choosen torch functions
- torch.tensor()
- torch.randn()
- torch.arange()
- torch.flatten()
- Matrix multiplications - torch.mm() torch.mv()
- torch.argmax()
- torch.Tensor.item()
Function 1 - torch.tensor
This function converts input data to a tensor and the input data can be a list, tuple, NumPy array, scalar, and other types.
#Example 1 - working
tensor_1 = torch.tensor([1,2,3,4])
tensor_1
tensor([1, 2, 3, 4])