Learn practical skills, build real-world projects, and advance your career
Updated 3 years ago
operations of pytorch
PyTorch :
-
1.PyTorch is a small part of a computer software which is based on Torch library. It is a Deep Learning framework introduced by Facebook. PyTorch is a Machine Learning Library for Python programming language which is used for applications such as Natural Language Processing.
-
2.The high-level features which are provided by PyTorch are as follows:
- With the help of the Graphics Processing Unit (GPU), it gives tensor computing with strong acceleration.
- It provides Deep Neural Network which is built on a tape-based auto diff system.
-
3.PyTorch was developed to provide high flexibility and speed during implementing and building the Deep Learning Neural Network.
-
4.It is quite simple to install, run, and understand. Pytorch is completely pythonic (using widely adopted python idioms rather than writing Java and C++ code) so that it can quickly build a Neural Network Model successfully.
Functions explained in this note book are:
- torch.acos()
- torch.abs()
- torch.complex()
- torch.bitwise_or()
- torch.matrix_rank()
# Uncomment and run the appropriate command for your operating system, if required
# Linux / Binder
# !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
# 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
# MacOS
# !pip install numpy torch torchvision torchaudio
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: 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: dataclasses in /opt/conda/lib/python3.8/site-packages (from torch==1.7.0+cpu) (0.6)
Requirement already satisfied: pillow>=4.1.1 in /opt/conda/lib/python3.8/site-packages (from torchvision==0.8.1+cpu) (8.0.0)
# Import torch and other required modules
import torch
Function 1 - torch.acos
- This function computes the inverse cosine of each element in the tensor
- Syntax : torch.acos(input)
- Output element of output tensor = inverse cosine of Input element of input tensor.
# Example 1 - working
torch.acos(torch.randn(1,2,3))
tensor([[[2.0638, nan, 2.0940],
[1.5608, nan, 2.3707]]])