Apply transforms to 4d tensor of images in my custom data loader

trans = transforms.Compose([
transforms.ToPILImage(),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

i want to apply this transform to 4d tensor (n, 3, 224, 224) and get a tensor in return.

1 Like

Unfortunately some of the torchvision transforms have some limitations to what dimensionality they can handle (namely transforms intended for PIL Images). However if you just wish to normalize the data, you can use transforms.Normalize() on any N dim data given that you convert the data to a Torch Tensor in your data loader.