Based on your code, you could probably create two different datasets and set the train argument appropriately:
train_dataset = Dataset(train=True)
val_dataset = Dataset(train=False)
train_loader = DataLoader(train_dataset)
val_loader = DataLoader(val_dataset)

Let me know, if I misunderstood the question.