You could preprocess the data once (using the current dataset) and save the preprocessed data as tensor (using torch.save). You could then load your already preprocessed data using torch.load by writing a new dataset which deals with the preprocessed data. If you have enough RAM to contain your whole Dataset you could do it in your new dataset’s __init__. If that’s not the case, just do it in your new dataset’s __getitem__.