In [1]: torch.autograd.Variable(torch.Tensor([float('inf')])).sum()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-635-a58935204698> in <module>()
----> 1 torch.autograd.Variable(torch.Tensor([float('inf')])).sum()
RuntimeError: value cannot be converted to type double without overflow: inf
In [2]: torch.__version__
Out[636]: '0.3.0.post4'
But in Tensor is OK
In [3]: torch.Tensor([float('inf')]).sum()
Out[3]: inf
BTW, generally how to handle the inf in Variable or Tensor?
The issue here is that Tensor.sum returns a numeric value, while Variable.sum gives a Variable. Generally one doesn’t want inf to occur. What is your use case?
Hi, It seems that the Variable cannot handle those operations with inf item.
But, I think you can try replace the inf with a larger value using torch.clamp()@herleeyandi