I have two Dataloader for train dataset and val dataset. However, when I use:
train_iter = iter(trainloader)

It seems to be ok. But if I want to use anthor iterator to test data, I try to:
val_iter = iter(valloader)

I got error: TypeError: ‘int’ object is not callable. Besides, if train_iter came to the end and get StopIteration, I want to delete train_iter and redefine it again for training, I got the same error.  The code is as follow:
 try:
    image, label = data_iter.next()
except StopIteration:
    del data_iter
    data_iter = iter(trainloader)
    image, label = data_iter.next()

Why I cannot use second dataloader iterator, how to fix it?