评价此页

ReLU#

class torch.nn.modules.activation.ReLU(inplace=False)[源代码]#

逐元素应用线性整流单元函数。

ReLU(x)=(x)+=max(0,x)\text{ReLU}(x) = (x)^+ = \max(0, x)

参数

inplace (bool) – 可以选择是否就地执行操作。默认值:False

形状
  • 输入: ()(*),其中 * 表示任意数量的维度。

  • 输出: ()(*),形状与输入相同。

../_images/ReLU.png

示例

  >>> m = nn.ReLU()
  >>> input = torch.randn(2)
  >>> output = m(input)


An implementation of CReLU - https://arxiv.org/abs/1603.05201

  >>> m = nn.ReLU()
  >>> input = torch.randn(2).unsqueeze(0)
  >>> output = torch.cat((m(input), m(-input)))
extra_repr()[源代码]#

返回模块的额外表示。

返回类型

str

forward(input)[源代码]#

执行前向传播。

返回类型

张量