After checking your code I find you are using pytorch 0.3.0, Variable and Tensor were not merged before pytorch v0.4.0, so you need to convert your model input to Variable  , i.e. Variable(gray_img_tensor)