Shahid Akhtar Khan has Published 216 Articles

PyTorch – How to compute the error function of a tensor?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 07-Jan-2022 06:10:14

298 Views

To compute the error function of a tensor, we use the torch.special.erf() method. It returns a new tensor with computed error function. It accepts torch tensor of any dimension. It is also known as Gauss error functionStepsWe could use the following steps to compute the error function of a tensor ... Read More

PyTorch – How to compute the eigenvalues and eigenvectors of a square matrix?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 07-Jan-2022 06:08:11

1K+ Views

torch.linalg.eig() computes the Eigen value decomposition of a square matrix or a batch of square matrices. It accepts matrix and batch of matrices of float, double, cfloat and cdouble data types. It returns a named tuple (eigenvalues, eigenvectors). The eigenvalues and eigenvectors are always complex valued. The eigenvectors are given ... Read More

PyTorch – How to invert the colors of an image randomly with a given probability?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 13:47:32

558 Views

The RandomInvert() transform inverts the colors of an image randomly with a given probability. The torchvision.transforms module provides many important transforms that can be used to perform different types of manipulations on the image data.RandomInvert() accepts both PIL and tensor images or batch of tensor images. A tensor image is ... Read More

PyTorch – How to rotate an image by an angle?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 13:34:31

5K+ Views

RandomRotation() rotates an image by a random angle. The chosen random angle is from a given range of angles in degree. RandomRotation() is one of the many important transforms provided by the torchvision.transforms module. RandomRotation() transform accepts both PIL and tensor images.A tensor image is a Torch tensor with shape ... Read More

How to pad an image on all sides in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 13:32:59

3K+ Views

To pad an image on all sides, we can apply Pad() transform provided by the torchvision.transforms module. This module contains many important transformations that can be used to perform different types of manipulations on the image data.Pad() transformation accepts both PIL and tensor images or a batch of tensor images. ... Read More

PyTorch – How to compute element-wise entropy of an input tensor?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 13:29:57

2K+ Views

To compute the element-wise entropy of an input tensor, we use torch.special.entr() method. It returns a new tensor with entropy computed element-wise.If the element of tensor is negative, the entropy is negative infinity.If the element of the tensor is a zero, the entropy is zero.The entropy for a positive number element ... Read More

PyTorch – torchvision.transforms – RandomErasing()

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 13:04:01

1K+ Views

The RandomErasing() transform randomly selects a rectangular region in an input image and erases its pixels. The torchvision.transforms module provides many important transforms that can be used to perform different types of manipulations on the image data. RandomErasing() transformation accepts only tensor images of any size. A tensor image is ... Read More

PyTorch – How to normalize an image with mean and standard deviation?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 12:28:30

6K+ Views

The Normalize() transform normalizes an image with mean and standard deviation. The torchvision.transforms module provides many important transforms that can be used to perform different types of manipulations on the image data.Normalize() accepts only tensor images of any size. A tensor image is a torch tensor. A tensor image may ... Read More

PyTorch – torchvision.transforms – GaussianBlur()

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 11:42:24

6K+ Views

The torchvision.transforms module provides many important transformations that can be used to perform different types of manipulations on the image data. GaussianBlur() transformation is used to blur an image with randomly chosen Gaussian blur.The GaussianBlur() transformation accepts both PIL and tensor images or a batch of tensor images. A tensor ... Read More

PyTorch – How to resize an image to a given size?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 06-Jan-2022 11:38:02

30K+ Views

The Resize() transform resizes the input image to a given size. It's one of the transforms provided by the torchvision.transforms module. Resize() accepts both PIL and tensor images. A tensor image is a torch tensor with shape [C, H, W], where C is the number of channels, H is the ... Read More

Advertisements