agadetsky
(Artyom)
December 11, 2017, 3:03am
1
Traceback (most recent call last):
File “”, line 1, in
RuntimeError: softplus(): argument ‘input’ (position 1) must be Variable, not torch.FloatTensor
Why softplus doesn’t work without Variable(…) wrapper?
Doesn’t torch.nn.functional.softplus(Variable(tensor)).data seem ugly?
Pytorch versions: 0.3.0.post4, 0.2.0.post4’
jdhao
(jdhao)
December 11, 2017, 4:10am
2
nn.funtional
are supposed to work with torch Variable
not the plain Tensor
. Ref here .
agadetsky
(Artyom)
December 11, 2017, 4:21am
3
So the only way out at the moment is to use F.softplus(Variable(x)).data
until Variable and Tensor will be merged, because torch.log(torch.exp(x) + 1)
is not as numerically stable as F.softplus
?
jdhao
(jdhao)
December 11, 2017, 6:00am
4
I suppose so. Or you can find the source code of softplus and see how it is implemented.
SimonW
(Simon Wang)
December 11, 2017, 6:24am
5
Variable and Tensor will be merged into one class in near future.