Now I’m fully understood. I was confused in iteration in dataloader and outside loop of dataloader… Thank you very much for replying.
Can I ask you another question regarding to code on the very top?
I changed epoch to 10 which will make 3607 data go through the model 10 times.
I didn’t touch the rest of the hyperparameters.
the average cost were all nan.
3607
start training
Epoch: 001 cost = nan time :  143.31351041793823
Epoch: 002 cost = nan time :  144.00150156021118
Epoch: 003 cost = nan time :  143.94768810272217
Epoch: 004 cost = nan time :  144.0049524307251
Epoch: 005 cost = nan time :  143.99128079414368
Epoch: 006 cost = nan time :  143.97400498390198
Epoch: 007 cost = nan time :  143.93819332122803
Epoch: 008 cost = nan time :  144.09143900871277
Epoch: 009 cost = nan time :  143.93545937538147
Epoch: 010 cost = nan time :  143.99345064163208
training Finished!

Do you have any idea why the average cost in each epoch is all nan?