Cast a Tensor to another Type in PyTorch

We can cast a Tensor to another type in PyTorch as below: import torch # Create a float tensor y = torch.randn(5, 5) # Cast the flost tensor to int tensor in pytorch y = y.int() Cast a Tensor to another Type in PyTorch Neural Network Machine Learning Algorithm From Scratch in Python is a … Continue reading Cast a Tensor to another Type in PyTorch

Using torchvision transforms for data augmentation

Transforms are common image transformations. torchvision transforms are used to augment the data with scaling, rotations, mirroring, cropping etc. Transforms are common image transformations.  Let us create some possible transforms like RandomRotation , Resize, RandomResizedCrop etc. Below is the code to use transforms for the training, validation, and testing sets transforms.Compose([transforms.Resize(224),transforms.CenterCrop(64),transforms.ToTensor()]) Most neural networks expect the … Continue reading Using torchvision transforms for data augmentation