title: RuntimeError: Only Tensors of floating point dtype can require gradients
body: <p>RuntimeError: Only Tensors of floating point dtype can require gradients
  <br/>
  got following error from </p>
  
  <blockquote>
    <p>input = Variable(preprocessed_img, requires_grad = True)</p>
  </blockquote>
  
  <pre><code>img=train_loader.dataset.data[0]
  print(type(img))
  img_tensor = torch.tensor(img)
  preprocess_image(img)
  
  &gt; def preprocess_image(img):    means=[0.485, 0.456, 0.406]     stds=[0.229,
  &gt; 0.224, 0.225]
  &gt; 
  &gt;   preprocessed_img = img.copy()[: , :, ::-1]  for i in range(3):
  &gt;       preprocessed_img[:, :, i] = preprocessed_img[:, :, i] - means[i]
  &gt;       preprocessed_img[:, :, i] = preprocessed_img[:, :, i] / stds[i]
  &gt;   preprocessed_img = \
  &gt;       np.ascontiguousarray(np.transpose(preprocessed_img, (2, 0, 1)))
  &gt;   preprocessed_img = torch.from_numpy(preprocessed_img)
  &gt;   preprocessed_img.unsqueeze_(0)  input = Variable(preprocessed_img,
  &gt; requires_grad = True)     return input
  </code></pre>