Please consider replacing img_batch, label_batch = dataiter.**next()** with img_batch, label_batch = **next(dataiter)** 