Hello everyone, I want to know if we can access the Dataset object after creation of DataLoader object.
Motivation : suppose we have a simple Dataset, -
class ExampleDataset(torch.utils.data.Dataset):
def __init__(self, data):
self.data = data
def __getitem__(self, index):
return self.data[index]
def __len__(self):
return len(self.data)
There is nothing tricky, - we can’t really modify any parameters here which can affect your training.
What I want to do is, -
class TrickyDataset(torch.utils.data.Dataset):
def __init__(self, data, aug_functions):
self.data = data
self.current_epoch = 0
self.light_aug = aug_functions[0]
self.medium_aug = aug_functions[1]
self.hard_aug = aug_function[2]
def __getitem__(self, index):
if self.current_epoch < 10:
return self.light_aug(self.data[index])
... etc
def update_epoch(self, epoch):
self.current_epoch = epoch
def __len__(self):
return len(self.data)
So, if we have some
TrickyLoader = torch.utils.data.DataLoader(TrickyDataset(*params))
Can we modify Dataset inside during training (because I want to change the way data is being augmented during training)?