Data Analytics in Marketing

These days we are producing and analyzing massive quantities of data, and it can sometimes prove to be overwhelming. This is especially true in marketing where it’s becoming more difficult to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Introduction to PyTorch Library and exploring few PyTorch Tensor functions

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.

Here, we are going to discuss five PyTorch tensor functions.

Firstly, to work with PyTorch library we need to import torch.

torch.floor(input, out=None) → Tensor

Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element.

We can use floor() function whenever we need the floor of any tensor.

Returns the numerical rank of a 2-D tensor. The method to compute the matrix rank is done using SVD by default. If symmetric is True, then input is assumed to be symmetric, and the computation of the rank is done by obtaining the eigenvalues.

torch.t(input) → Tensor

The torch.t function transposes your tensor based on the dimensions of that tensor. So if you had a (n, d) tensor and decided to transpose it, the new tensor would be a (d, n) tensor. Expects input to be <= 2-D tensor and transposes dimensions 0 and 1.

This function is useful for transposing matrices and would help whenever we need to perform matrix multiplication or finding the dot product of two matrices.

torch.div(input, other, out=None) → Tensor

Divides each element of the input with the scalar and returns a new resulting tensor.

In the above example, a random tensor with 5 floating values has been initialized and when given input to torch.div function along with the scalar with which we want to divide, it returns a new tensor.

We can use this function whenever we want to divide all elements in the tensor with a value or another tensor of same size.

torch.ne(input, other, out=None) → Tensor

Computes input!= other element-wise.

The second argument can be a number or a tensor whose shape is broadcastable with the first argument.

This function can be used whenever we want to check if 2 tensors are not equal.

This is brief introduction to PyTorch and some functions in the PyTorch tensor library. If you’d like to know more about these functions, you can visit the official PyTorch documentation for more information.

For those interested in learning more about Deep Learning with PyTorch, I would recommend you to follow jovian.ml

Official documentation for torch.Tensor:

Add a comment

Related posts:

Scientists Engineering MEGA Drive for Manned Interstellar Travel

In the deep space adventure world of Star Trek, high-tech ships are propelled forward with incredible efficiency by utilizing something known as an “impulse drive”. This drive allows them to travel…

Investing into Crypto Tokens with Tokenizer.biz

Learn more about Tokenizer via the url — https://tokenizer.biz. “Investing into Crypto Tokens with Tokenizer.biz” is published by Tokenizer Cryptocurrency Solutions Limited.