【PyTorch】教程:torch.nn.LogSigmoid

torch.nn.LogSigmoid

原型

CLASS torch.nn.LogSigmoid()

参数

shape

  • Input: (*), * 代表任意维度
  • Output: (*), 与输入相同

定义

LogSigmoid ( x ) = log ⁡ ( 1 1 + exp ⁡ ( − x ) ) \text{LogSigmoid}(x) = \log\left(\frac{ 1 }{ 1 + \exp(-x)}\right) LogSigmoid(x)=log(1+exp(x)1)

在这里插入图片描述

代码

import torch
import torch.nn as nn

m = nn.LogSigmoid()
input = torch.randn(4)
output = m(input)

print("input: ", input)   # input:  tensor([-0.1181,  1.8792, -0.1737, -0.6441])
print("output: ", output) # output:  tensor([-0.7539, -0.1421, -0.7838, -1.0662])

【参考】

LogSigmoid — PyTorch 1.13 documentation

猜你喜欢

转载自blog.csdn.net/zhoujinwang/article/details/129351631