I would like to filter out my dataset every epoch by changing the sampler for the data loader, but when I change the sampler it gives me :
ValueError: sampler attribute should not be set after DataLoader is initialized
here’s my sample code :
def train_test():
epoch = epoch_n
for e in range(epoch):
train_loss, train_acuracy, losses = train(train_loader,criterion,optimizer,e+1,True)
test_loss, test_acuracy = test(test_loader,criterion,optimizer,e+1,True)
print('Epoch %d, Training Loss/Acc: %f//%f, Testing Loss/Acc: %f//%f' % (e+1,train_loss,train_acuracy,test_loss,test_acuracy))
indexsorted = rankloss(losses)
indexcuted = cutdataset(indexsorted)
train_loader.sampler = sampler.SubsetRandomSampler(indexcuted)
is there a way to do this ?