Solved by AlbertZhang in post #5 
              
              
                I have fixed the problem. In fact the format data flow in a neural network is tensor, which means that  returns of the methods  forward and backward should be tensors. So I eliminated the Variable operation. That works fine!