評價此頁

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)[原始碼]#

執行前向傳播。

返回型別

張量