Solved by Angry_potato in post #3 
              
              
                Thank you for the reply. I found the solution on another website. 
Simply change all the parameters of model to float by using net.float() before loss and convert the input to float.