Hi @richard, Thanks a lot for your help!
Yes, I tested your method and it is working perfectly! Thanks a lot!
I have another question. When I use the code on images with batch size 128, the memory of GPU is blown up.  I then got an out of memory error. Do you have any suggestions on that?
Thanks again!