Introduction to PyTorch Library and exploring few PyTorch Tensor functions
This is a short introduction to PyTorch Library and some functions used in PyTorch tensor.
PyTorch is an open source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab. It is free and open-source software released under the Modified BSD (Berkeley Software Distribution) license.
A short introduction about PyTorch and about the chosen functions.
PyTorch is defined as an open source machine learning library for Python. It is used for applications such as natural language processing.
Below are some functions in PyTorch library.
- torch.floor
- torch.matrix_rank
- torch.t
- torch.div
- torch.ne
# Import torch and other required modules
import torch
Function 1 - torch.floor()
Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element.
# Example 1 - working
a = torch.randn(4)
print(a)
torch.floor(a)
tensor([ 1.7987, -1.8716, -0.5400, 1.3027])
torch.float32
The above example returns a tensor with floor of elements of 4 random floating numbers.