激活函数sigmoid
input = torch.randn(2,3)
print(input)
tensor([[-0.2863, 0.1606, -0.6738],
[ 0.3379, -0.5613, 0.3672]])
X = torch.tensor([[1,2,3],[2,3,4]])
Y = mod(X)
print(Y)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-39-dac9d1ea9cc0> in <module>()
1 X = torch.tensor([[1,2,3],[2,3,4]])
----> 2 Y = mod(X)
3 print(Y)
E:\soft2\annaconda\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)
E:\soft2\annaconda\lib\site-packages\torch\nn\modules\activation.py in forward(self, input)
269
270 def forward(self, input):
--> 271 return torch.sigmoid(input)
272
273
RuntimeError: "sigmoid_cpu" not implemented for 'Long'
X = torch.tensor([[0.1,0.2,0.3],[0.2,0.3,0.4]])
print(X)
mod = nn.Sigmoid()
Y = mod(X)
y = mod(input)
print(Y)
print(y)
tensor([[0.1000, 0.2000, 0.3000],
[0.2000, 0.3000, 0.4000]])
tensor([[0.5250, 0.5498, 0.5744],
[0.5498, 0.5744, 0.5987]])
tensor([[0.4289, 0.5401, 0.3377],
[0.5837, 0.3633, 0.5908]])
- 以上例子说明nn的sigmoid函数不支持大于1的数