torch.nn.ReLU6
原型
CLASS torch.nn.ReLU6(inplace=False)
参数
- inplace (bool) – can optionally do the operation in-place. Default: False
定义
ReLU6 ( x ) = min ( max ( 0 , x ) , 6 ) \text{ReLU6}(x)=\min(\max(0, x), 6) ReLU6(x)=min(max(0,x),6)
图
代码
import torch
import torch.nn as nn
m = nn.ReLU6()
input = torch.randn(4)
output = m(input)
print("input: ", input) # input: tensor([-0.0236, 0.9640, 0.2721, 2.5475])
print("output: ", output) # output: tensor([0.0000, 0.9640, 0.2721, 2.5475])