# Windows
!pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html Requirement already satisfied: numpy in /opt/conda/lib/python3.8/site-packages (1.19.2) Requirement already satisfied: torch==1.7.0+cpu in /opt/conda/lib/python3.8/site-packages (1.7.0+cpu) Requirement already satisfied: torchvision==0.8.1+cpu in /opt/conda/lib/python3.8/site-packages (0.8.1+cpu) Requirement already satisfied: torchaudio==0.7.0 in /opt/conda/lib/python3.8/site-packages (0.7.0) Requirement already satisfied: dataclasses in /opt/conda/lib/python3.8/site-packages (from torch==1.7.0+cpu) (0.6) Requirement already satisfied: future in /opt/conda/lib/python3.8/site-packages (from torch==1.7.0+cpu) (0.18.2) Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.8/site-packages (from torch==1.7.0+cpu) (3.7.4.3) Requirement already satisfied: pillow>=4.1.1 in /opt/conda/lib/python3.8/site-packages (from torchvision==0.8.1+cpu) (8.0.0)

An short introduction about PyTorch

The most basic building block of any Deep Learning library is the tensor. Tensors are matrix-like data structures very similar in function and properties to Numpy arrays. In fact, for most purposes you can think of them exactly like Numpy arrays. The most important difference between the two is that the implementation of tensors in modern Deep Learning libraries can run on CPU or GPU (very fast).

5 functions related to PyTorch tensors

  • function 1 - torch.view()
  • function 2 -TORCH.QUANTIZE_PER_CHANNEL
  • function 3 - torch.save
  • function 4 - torch.acos
  • function 5 - torch.bitwise_not
    Before we begin, let's install and import PyTorch
import torch

Function 1 - torch.view()

This function returns a new tensor with the same data as the original tensor but of a different shape.

# Example 1 - working
tensor1 = torch.tensor([[1, 2], [3, 4.]])
tensor1
tensor([[1., 2.],
        [3., 4.]])