I change all the iter(dataloader) to dataloader.iter(). For example:
train_iter = trainloader.__iter__()
val_iter = valloader.__iter__()

Everything is ok. But I cannot find out what happened. Could anyone tell me why?