Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
e0be63bf
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0be63bf
编写于
12月 26, 2017
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change activations
上级
874cac0c
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
267 addition
and
238 deletion
+267
-238
paddle/operators/activation_op.cc
paddle/operators/activation_op.cc
+59
-59
paddle/operators/activation_op.h
paddle/operators/activation_op.h
+208
-179
未找到文件。
paddle/operators/activation_op.cc
浏览文件 @
e0be63bf
...
...
@@ -22,8 +22,8 @@ class ActivationOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
ctx
->
SetOutputDim
(
"
Y
"
,
ctx
->
GetInputDim
(
"X"
));
ctx
->
ShareLoD
(
"X"
,
/*->*/
"
Y
"
);
ctx
->
SetOutputDim
(
"
Out
"
,
ctx
->
GetInputDim
(
"X"
));
ctx
->
ShareLoD
(
"X"
,
/*->*/
"
Out
"
);
}
};
...
...
@@ -32,7 +32,7 @@ class ActivationOpGrad : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
ctx
->
GetInputDim
(
"
Y
"
));
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
ctx
->
GetInputDim
(
"
Out
"
));
}
};
...
...
@@ -41,11 +41,11 @@ class SigmoidOpMaker : public framework::OpProtoAndCheckerMaker {
SigmoidOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Sigmoid operator"
);
AddOutput
(
"
Y
"
,
"Output of Sigmoid operator"
);
AddOutput
(
"
Out
"
,
"Output of Sigmoid operator"
);
AddComment
(
R"DOC(
Sigmoid Activation Operator
$$
y
= \frac{1}{1 + e^{-x}}$$
$$
out
= \frac{1}{1 + e^{-x}}$$
)DOC"
);
}
...
...
@@ -56,11 +56,11 @@ class LogSigmoidOpMaker : public framework::OpProtoAndCheckerMaker {
LogSigmoidOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of LogSigmoid operator"
);
AddOutput
(
"
Y
"
,
"Output of LogSigmoid operator"
);
AddOutput
(
"
Out
"
,
"Output of LogSigmoid operator"
);
AddComment
(
R"DOC(
Logsigmoid Activation Operator
$$
y
= \log \frac{1}{1 + e^{-x}}$$
$$
out
= \log \frac{1}{1 + e^{-x}}$$
)DOC"
);
}
...
...
@@ -71,11 +71,11 @@ class ExpOpMaker : public framework::OpProtoAndCheckerMaker {
ExpOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Exp operator"
);
AddOutput
(
"
Y
"
,
"Output of Exp operator"
);
AddOutput
(
"
Out
"
,
"Output of Exp operator"
);
AddComment
(
R"DOC(
Exp Activation Operator.
$
y
= e^x$
$
out
= e^x$
)DOC"
);
}
...
...
@@ -86,11 +86,11 @@ class ReluOpMaker : public framework::OpProtoAndCheckerMaker {
ReluOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Relu operator"
);
AddOutput
(
"
Y
"
,
"Output of Relu operator"
);
AddOutput
(
"
Out
"
,
"Output of Relu operator"
);
AddComment
(
R"DOC(
Relu Activation Operator.
$
y
= \max(x, 0)$
$
out
= \max(x, 0)$
)DOC"
);
}
...
...
@@ -101,12 +101,12 @@ class LeakyReluOpMaker : public framework::OpProtoAndCheckerMaker {
LeakyReluOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of LeakyRelu operator"
);
AddOutput
(
"
Y
"
,
"Output of LeakyRelu operator"
);
AddOutput
(
"
Out
"
,
"Output of LeakyRelu operator"
);
AddAttr
<
float
>
(
"alpha"
,
"The small negative slope"
).
SetDefault
(
0.02
f
);
AddComment
(
R"DOC(
LeakyRelu Activation Operator.
$
y
= \max(x, \alpha * x)$
$
out
= \max(x, \alpha * x)$
)DOC"
);
}
...
...
@@ -117,13 +117,13 @@ class SoftShrinkOpMaker : public framework::OpProtoAndCheckerMaker {
SoftShrinkOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Softshrink operator"
);
AddOutput
(
"
Y
"
,
"Output of Softshrink operator"
);
AddOutput
(
"
Out
"
,
"Output of Softshrink operator"
);
AddAttr
<
float
>
(
"lambda"
,
"non-negative offset"
).
SetDefault
(
0.5
f
);
AddComment
(
R"DOC(
Softshrink Activation Operator.
$$
y
= \begin{cases}
out
= \begin{cases}
x - \lambda, \text{if } x > \lambda \\
x + \lambda, \text{if } x < -\lambda \\
0, \text{otherwise}
...
...
@@ -139,11 +139,11 @@ class TanhOpMaker : public framework::OpProtoAndCheckerMaker {
TanhOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Tanh operator"
);
AddOutput
(
"
Y
"
,
"Output of Tanh operator"
);
AddOutput
(
"
Out
"
,
"Output of Tanh operator"
);
AddComment
(
R"DOC(
Tanh Activation Operator.
$$
y
= \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}$$
$$
out
= \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}$$
)DOC"
);
}
...
...
@@ -154,11 +154,11 @@ class TanhShrinkOpMaker : public framework::OpProtoAndCheckerMaker {
TanhShrinkOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of TanhShrink operator"
);
AddOutput
(
"
Y
"
,
"Output of TanhShrink operator"
);
AddOutput
(
"
Out
"
,
"Output of TanhShrink operator"
);
AddComment
(
R"DOC(
TanhShrink Activation Operator.
$$
y
= x - \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}$$
$$
out
= x - \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}$$
)DOC"
);
}
...
...
@@ -169,14 +169,14 @@ class HardShrinkOpMaker : public framework::OpProtoAndCheckerMaker {
HardShrinkOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of HardShrink operator"
);
AddOutput
(
"
Y
"
,
"Output of HardShrink operator"
);
AddOutput
(
"
Out
"
,
"Output of HardShrink operator"
);
AddAttr
<
float
>
(
"threshold"
,
"The value of threshold for HardShrink"
)
.
SetDefault
(
0.5
f
);
AddComment
(
R"DOC(
HardShrink Activation Operator.
$$
y
= \begin{cases}
out
= \begin{cases}
x, \text{if } x > \lambda \\
x, \text{if } x < -\lambda \\
0, \text{otherwise}
...
...
@@ -192,11 +192,11 @@ class SqrtOpMaker : public framework::OpProtoAndCheckerMaker {
SqrtOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Sqrt operator"
);
AddOutput
(
"
Y
"
,
"Output of Sqrt operator"
);
AddOutput
(
"
Out
"
,
"Output of Sqrt operator"
);
AddComment
(
R"DOC(
Sqrt Activation Operator.
$
y
= \sqrt{x}$
$
out
= \sqrt{x}$
)DOC"
);
}
...
...
@@ -207,11 +207,11 @@ class AbsOpMaker : public framework::OpProtoAndCheckerMaker {
AbsOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Abs operator"
);
AddOutput
(
"
Y
"
,
"Output of Abs operator"
);
AddOutput
(
"
Out
"
,
"Output of Abs operator"
);
AddComment
(
R"DOC(
Abs Activation Operator.
$
y
= |x|$
$
out
= |x|$
)DOC"
);
}
...
...
@@ -222,11 +222,11 @@ class CeilOpMaker : public framework::OpProtoAndCheckerMaker {
CeilOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Ceil operator"
);
AddOutput
(
"
Y
"
,
"Output of Ceil operator"
);
AddOutput
(
"
Out
"
,
"Output of Ceil operator"
);
AddComment
(
R"DOC(
Ceil Activation Operator.
$
y
= ceil(x)$
$
out
= ceil(x)$
)DOC"
);
}
...
...
@@ -237,11 +237,11 @@ class FloorOpMaker : public framework::OpProtoAndCheckerMaker {
FloorOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Floor operator"
);
AddOutput
(
"
Y
"
,
"Output of Floor operator"
);
AddOutput
(
"
Out
"
,
"Output of Floor operator"
);
AddComment
(
R"DOC(
Floor Activation Operator.
$
y
= floor(x)$
$
out
= floor(x)$
)DOC"
);
}
...
...
@@ -252,11 +252,11 @@ class RoundOpMaker : public framework::OpProtoAndCheckerMaker {
RoundOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Round operator"
);
AddOutput
(
"
Y
"
,
"Output of Round operator"
);
AddOutput
(
"
Out
"
,
"Output of Round operator"
);
AddComment
(
R"DOC(
Round Activation Operator.
$
y
= [x]$
$
out
= [x]$
)DOC"
);
}
...
...
@@ -267,11 +267,11 @@ class ReciprocalOpMaker : public framework::OpProtoAndCheckerMaker {
ReciprocalOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Reciprocal operator"
);
AddOutput
(
"
Y
"
,
"Output of Reciprocal operator"
);
AddOutput
(
"
Out
"
,
"Output of Reciprocal operator"
);
AddComment
(
R"DOC(
Reciprocal Activation Operator.
$$
y
= \frac{1}{x}$$
$$
out
= \frac{1}{x}$$
)DOC"
);
}
...
...
@@ -282,11 +282,11 @@ class LogOpMaker : public framework::OpProtoAndCheckerMaker {
LogOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Log operator"
);
AddOutput
(
"
Y
"
,
"Output of Log operator"
);
AddOutput
(
"
Out
"
,
"Output of Log operator"
);
AddComment
(
R"DOC(
Log Activation Operator.
$
y
= \ln(x)$
$
out
= \ln(x)$
Natural logarithm of x.
...
...
@@ -299,11 +299,11 @@ class SquareOpMaker : public framework::OpProtoAndCheckerMaker {
SquareOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Square operator"
);
AddOutput
(
"
Y
"
,
"Output of Square operator"
);
AddOutput
(
"
Out
"
,
"Output of Square operator"
);
AddComment
(
R"DOC(
Square Activation Operator.
$
y
= x^2$
$
out
= x^2$
)DOC"
);
}
...
...
@@ -314,11 +314,11 @@ class SoftplusOpMaker : public framework::OpProtoAndCheckerMaker {
SoftplusOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Softplus operator"
);
AddOutput
(
"
Y
"
,
"Output of Softplus operator"
);
AddOutput
(
"
Out
"
,
"Output of Softplus operator"
);
AddComment
(
R"DOC(
Softplus Activation Operator.
$
y
= \ln(1 + e^{x})$
$
out
= \ln(1 + e^{x})$
)DOC"
);
}
...
...
@@ -329,11 +329,11 @@ class SoftsignOpMaker : public framework::OpProtoAndCheckerMaker {
SoftsignOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Softsign operator"
);
AddOutput
(
"
Y
"
,
"Output of Softsign operator"
);
AddOutput
(
"
Out
"
,
"Output of Softsign operator"
);
AddComment
(
R"DOC(
Softsign Activation Operator.
$$
y
= \frac{x}{1 + |x|}$$
$$
out
= \frac{x}{1 + |x|}$$
)DOC"
);
}
...
...
@@ -344,7 +344,7 @@ class BReluOpMaker : public framework::OpProtoAndCheckerMaker {
BReluOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of BRelu operator"
);
AddOutput
(
"
Y
"
,
"Output of BRelu operator"
);
AddOutput
(
"
Out
"
,
"Output of BRelu operator"
);
AddAttr
<
float
>
(
"t_min"
,
"The min marginal value of BRelu"
)
.
SetDefault
(
static_cast
<
float
>
(
0
));
AddAttr
<
float
>
(
"t_max"
,
"The max marginal value of BRelu"
)
...
...
@@ -352,7 +352,7 @@ class BReluOpMaker : public framework::OpProtoAndCheckerMaker {
AddComment
(
R"DOC(
BRelu Activation Operator.
$
y
= \max(\min(x, t_{min}), t_{max})$
$
out
= \max(\min(x, t_{min}), t_{max})$
)DOC"
);
}
...
...
@@ -363,13 +363,13 @@ class SoftReluOpMaker : public framework::OpProtoAndCheckerMaker {
SoftReluOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of SoftRelu operator"
);
AddOutput
(
"
Y
"
,
"Output of SoftRelu operator"
);
AddOutput
(
"
Out
"
,
"Output of SoftRelu operator"
);
AddAttr
<
float
>
(
"threshold"
,
"The threshold value of SoftRelu"
)
.
SetDefault
(
40.0
f
);
AddComment
(
R"DOC(
SoftRelu Activation Operator.
$
y
= \ln(1 + \exp(\max(\min(x, threshold), threshold))$
$
out
= \ln(1 + \exp(\max(\min(x, threshold), threshold))$
)DOC"
);
}
...
...
@@ -380,7 +380,7 @@ class ELUOpMaker : public framework::OpProtoAndCheckerMaker {
ELUOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of ELU operator"
);
AddOutput
(
"
Y
"
,
"Output of ELU operator"
);
AddOutput
(
"
Out
"
,
"Output of ELU operator"
);
AddAttr
<
float
>
(
"alpha"
,
"The alpha value of ELU"
).
SetDefault
(
1.0
f
);
AddComment
(
R"DOC(
ELU Activation Operator.
...
...
@@ -388,7 +388,7 @@ ELU Activation Operator.
Applies the following element-wise computation on the input according to
https://arxiv.org/abs/1511.07289.
$
y
= \max(0, x) + \min(0, \alpha * (e^x - 1))$
$
out
= \max(0, x) + \min(0, \alpha * (e^x - 1))$
)DOC"
);
}
...
...
@@ -399,13 +399,13 @@ class Relu6OpMaker : public framework::OpProtoAndCheckerMaker {
Relu6OpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Relu6 operator"
);
AddOutput
(
"
Y
"
,
"Output of Relu6 operator"
);
AddOutput
(
"
Out
"
,
"Output of Relu6 operator"
);
AddAttr
<
float
>
(
"threshold"
,
"The threshold value of Relu6"
)
.
SetDefault
(
6.0
f
);
AddComment
(
R"DOC(
Relu6 Activation Operator.
$
y
= \min(\max(0, x), 6)$
$
out
= \min(\max(0, x), 6)$
)DOC"
);
}
...
...
@@ -416,12 +416,12 @@ class PowOpMaker : public framework::OpProtoAndCheckerMaker {
PowOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Pow operator"
);
AddOutput
(
"
Y
"
,
"Output of Pow operator"
);
AddOutput
(
"
Out
"
,
"Output of Pow operator"
);
AddAttr
<
float
>
(
"factor"
,
"The exponential factor of Pow"
).
SetDefault
(
1.0
f
);
AddComment
(
R"DOC(
Pow Activation Operator.
$
y
= x^{factor}$
$
out
= x^{factor}$
)DOC"
);
}
...
...
@@ -432,7 +432,7 @@ class STanhOpMaker : public framework::OpProtoAndCheckerMaker {
STanhOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of STanh operator"
);
AddOutput
(
"
Y
"
,
"Output of STanh operator"
);
AddOutput
(
"
Out
"
,
"Output of STanh operator"
);
AddAttr
<
float
>
(
"scale_a"
,
"The scale parameter of a for the input"
)
.
SetDefault
(
2.0
f
/
3.0
f
);
AddAttr
<
float
>
(
"scale_b"
,
"The scale parameter of b for the input"
)
...
...
@@ -440,7 +440,7 @@ class STanhOpMaker : public framework::OpProtoAndCheckerMaker {
AddComment
(
R"DOC(
STanh Activation Operator.
$$
y
= b * \frac{e^{a * x} - e^{-a * x}}{e^{a * x} + e^{-a * x}}$$
$$
out
= b * \frac{e^{a * x} - e^{-a * x}}{e^{a * x} + e^{-a * x}}$$
)DOC"
);
}
...
...
@@ -451,14 +451,14 @@ class ThresholdedReluOpMaker : public framework::OpProtoAndCheckerMaker {
ThresholdedReluOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of ThresholdedRelu operator"
);
AddOutput
(
"
Y
"
,
"Output of ThresholdedRelu operator"
);
AddOutput
(
"
Out
"
,
"Output of ThresholdedRelu operator"
);
AddAttr
<
float
>
(
"threshold"
,
"The threshold location of activation"
)
.
SetDefault
(
1.0
f
);
AddComment
(
R"DOC(
ThresholdedRelu Activation Operator.
$$
y
= \begin{cases}
out
= \begin{cases}
x, \text{if } x > threshold \\
0, \text{otherwise}
\end{cases}
...
...
@@ -473,7 +473,7 @@ class HardSigmoidOpMaker : public framework::OpProtoAndCheckerMaker {
HardSigmoidOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of HardSigmoid operator"
);
AddOutput
(
"
Y
"
,
"Output of HardSigmoid operator"
);
AddOutput
(
"
Out
"
,
"Output of HardSigmoid operator"
);
AddAttr
<
float
>
(
"slope"
,
"Slope for linear approximation of sigmoid"
)
.
SetDefault
(
0.2
f
);
AddAttr
<
float
>
(
"offset"
,
"Offset for linear approximation of sigmoid"
)
...
...
@@ -484,7 +484,7 @@ HardSigmoid Activation Operator.
Segment-wise linear approximation of sigmoid(https://arxiv.org/abs/1603.00391),
which is much faster than sigmoid.
$
y
= \max(0, \min(1, slope * x + shift))$
$
out
= \max(0, \min(1, slope * x + shift))$
The slope should be positive. The offset can be either positive or negative.
The default slope and shift are set according to the above reference.
...
...
@@ -499,12 +499,12 @@ class SwishOpMaker : public framework::OpProtoAndCheckerMaker {
SwishOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Swish operator"
);
AddOutput
(
"
Y
"
,
"Output of Swish operator"
);
AddOutput
(
"
Out
"
,
"Output of Swish operator"
);
AddAttr
<
float
>
(
"beta"
,
"Constant beta of swish operator"
).
SetDefault
(
1.0
f
);
AddComment
(
R"DOC(
Swish Activation Operator.
$$
y
= \frac{x}{1 + e^{- \beta x}}$$
$$
out
= \frac{x}{1 + e^{- \beta x}}$$
)DOC"
);
}
...
...
paddle/operators/activation_op.h
浏览文件 @
e0be63bf
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录