PCA while using Dataloaders

How do I apply PCA (from sklearn.decomposition) to an image dataset that I am loading using Dataloaders?
Is there a better way to load an image dataset in pytorch that would allow me to apply PCA?

I assume you’ve already calculated the eigenvectors and would like to transform each image using the them?
If so, you could lazily load your images in your Dataset's __getitem__ function and apply the PCA there.
Have a look at the data loading tutorial for more information on Dataset and DataLoader.

this worked! Thank you!