TorchVision Transforms: Image Preprocessing in PyTorch


TorchVision, a PyTorch computer vision package, has a great API for image pre-processing in its torchvision.transforms module. This post gives some basic usage examples, describes the API and shows you how to create and use custom image transforms.

PyTorch One Hot Encoding


PyTorch has a one_hot() function for converting class indices to one-hot encoded targets.

Normalizing Images in PyTorch


You can use the torchvision Normalize() transform to subtract the mean and divide by the standard deviation for image tensors in PyTorch. But it’s important to understand how the transform works and how to reverse it.

Cross Entropy Loss in PyTorch

Posted 2020-07-24 • Updated 2021-01-28

Cross entropy loss in PyTorch can be a little confusing. Here is a simple explanation of how it works for people who get stuck.

PyTorch Quick Start: Classifying an Image

Posted 2017-02-25 • Updated 2019-02-28

In this post we’ll classify an image with PyTorch. If you prefer to skip the prose, you can checkout the Jupyter notebook. Two interesting features of PyTorch are pythonic tensor manipulation that’s similar to numpy and dynamic computational graphs, which handle recurrent neural networks in a more natural way than static computational graphs. A good description …

PyTorch Quick Start: Classifying an Image Read More »