There are likely many ways of doing this depending on what “update the dataset” actually means. If you merely need to do something like tweak transformations, then this might be doable with some global state that is used by your transform/preprocessing functions. If it means adding or removing samples, then this becomes substantially trickier as it involves either changing the data loading iterator (torch.utils.data.dataloader — PyTorch 1.8.1 documentation) or building a new dataset and dataloader on the fly using the remaining data.