Pytorch Dataloader Sklearn PCA T-SNE

Hello, I am trying to apply PCA and T-SNE on an image dataset. I have the images in a Dataloader but I can’t figure how to use them as the X on the sklearn functions. Can anyone help?

These scikit-learn methods expect 2-dimensional numpy arrays as the input, so you could either pass a batch returned by the DataLoader to it (after calling numpy() on it and making sure the shape is right) or you could stack (some) batches and pass this larger array to it.