How to Create Normal Distribution in PyTorch?

The normal distribution is often utilized in statistics and probability where data is symmetrically distributed around the mean. It shows that data near the mean more frequently occurred than data far from the mean. Sometimes, users may be required to generate random...

Crop and Resize a Random Image Area in PyTorch

In PyTorch, the “torchvision.transforms” module has a collection of classes and functions to apply different transformations on desired images including rotating, cropping, resizing, and many more. It provides the “RandomResizedCrop()” method to crop a random area of...

How to Find Binary Cross Entropy in PyTorch?

Binary cross entropy is a logarithmic loss function utilized in machine learning. It computes the difference between the estimated probabilities of a model and actual labels of data. Sometimes, users may need to find/compute the binary cross entropy between two (input...

How to Flip an Image Horizontally in PyTorch?

PyTorch is a machine-learning library that offers various modules to work with images. The “torchvision.transforms” module from the PyTorch package  has a collection of classes and functions to perform various transformations on images including cropping,...