@ptrblck  Thanks. Could the problem be from this line?
train_loader,train_labels = next(data_gen(args.batch_size))
I tried to use pytorch dataloader but I got this error:
TypeError: object of type ‘generator’ has no len()
I used the same method of adding condition with MNIST dataset, but my dataset is different