Thank you very much @jpeg729 . I have added ‘model.hidden.detach_()’ in the loop code and it worked. I have never seen this feature in any tutorial before. I will try to look into it. Thanks again for your generous help.