Hi, Frank:
Thank you so so much!
Your answer has solved my problem. Appreciate that!!!
In fact, I changed my code with your advice and it worked. Actually, I met some little problem like,

Wrong Tensor Type: such as *(ops) indicated a bug:0 element has no grad_fn
2.dot() was not implemented for Long()
(These 2 bug I have solved)
So I am thinking, Could you please recommend me some lessons or something that I can learn pytorch systematically ? There are always too many bugs, dealing with them one by one is not efficient…
Thanks a lot !!!
Best.