Solved by albanD in post #4 
              
              
                Hi, 
You should remove all the calls to Variable and that should fix it: 
        img = img.view(img.size(0), -1)
        img = img.cuda().requires_grad_()
       
        noisy_img = add_noise(img)