Custom transform on minibatch during training loop

I wish to make a custom transform to apply to my images… DURING the training loop
I think I understand how to make transforms that apply during dataloader creation, but not during the loop.

Is there any guide, or method, to making a custom transform class object that can be applied during the training loop to minibatches for unsupervised learning (no labels)?

If you’re wondering why I can’t apply the transform during the dataloader step, it’s because I am training a generator, and need to apply the transform to the freshly-generated minibatches on each loop in order to calculate the loss function.

I am fairly new to pytorch, so thank you so much for any help!

Yes, torchvision.transforms can be applied on tensors in newer releases, so you could apply them inside the training loop on the data.

1 Like