现在,当torch.autograd.Variable与torch.tensor合并并过时时,为什么他们要弃用torch.nn.functional中的一些函数,而不是其他函数?也就是说,不推荐使用tanh,但不建议使用sigmoid或relu。
>>> torch.__version__
'1.1.0'
>>> u
tensor(2., grad_fn=<MeanBackward0>)
>>> torch.nn.functional.tanh(u)
C:\Users\mlearning\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\nn\functional.py:1374: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
tensor(0.9640, grad_fn=<TanhBackward>)
>>> torch.nn.functional.sigmoid(u)
tensor(0.8808, grad_fn=<SigmoidBackward>)
>>> torch.nn.functional.relu(u)
tensor(2., grad_fn=<ReluBackward0>)torch.nn.functional.relu和torch.relu之间有什么区别吗,或者我可以互换使用它们?
发布于 2019-06-24 01:01:57
https://stackoverflow.com/questions/56723486
复制相似问题