Using x = torch.randn(32, 1, 3, 3) works, but using my x tensor does’nt work
File "/home/paul/miniconda3/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 49, in __call__
    img = t(img)
  File "/home/paul/miniconda3/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 110, in __call__
    return F.to_pil_image(pic, self.mode)
  File "/home/paul/miniconda3/lib/python3.6/site-packages/torchvision/transforms/functional.py", line 109, in to_pil_image
    npimg = np.transpose(pic.numpy(), (1, 2, 0))
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.

I have tested this
x = att.view(b, 1, h, w)
print(x.size())  # ==> torch.Size([32, 1, 3, 3])
print(type(x))  # ==> <class 'torch.Tensor'>
x = torch.randn(32, 1, 3, 3)
print(x.size())  # ==> torch.Size([32, 1, 3, 3])
print(type(x))  # ==> <class 'torch.Tensor'>

So why mine doesn’t work
Thanks