class HardSigmoidOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "An N-D Tensor with data type float32, float64. ");
AddOutput("Out", "A Tensor with the same shape as input. ");
AddAttr<float>("slope",
"The slope of the linear approximation of sigmoid. Its "
"value MUST BE positive. Default is 0.2. ")
.SetDefault(0.2f);
AddAttr<float>(
"offset",
"The offset of the linear approximation of sigmoid. Default is 0.5. ")
.SetDefault(0.5f);
AddComment(R"DOC(
HardSigmoid Activation Operator.
bug描述 Describe the Bug
另外paddle/fluid/operators/activation_op.cc 默认的slope参数也是0.2
A 3-part piecewise linear approximation of sigmoid(https://arxiv.org/abs/1603.00391), which is much faster than sigmoid.
$$out = \max(0, \min(1, slope * x + offset))$$
)DOC"); } };