Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
a0a3a685
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,发现更多精彩内容 >>
提交
a0a3a685
编写于
5月 19, 2017
作者:
X
xuwei06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Sqrt and Reciprocal activation
上级
48de5ffc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
3 deletion
+101
-3
paddle/gserver/activations/ActivationFunction.cpp
paddle/gserver/activations/ActivationFunction.cpp
+38
-0
python/paddle/trainer_config_helpers/activations.py
python/paddle/trainer_config_helpers/activations.py
+25
-1
python/paddle/trainer_config_helpers/layer_math.py
python/paddle/trainer_config_helpers/layer_math.py
+2
-0
python/paddle/trainer_config_helpers/tests/configs/math_ops.py
...n/paddle/trainer_config_helpers/tests/configs/math_ops.py
+2
-0
python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr
...r_config_helpers/tests/configs/protostr/math_ops.protostr
+33
-1
python/paddle/v2/trainer.py
python/paddle/v2/trainer.py
+1
-1
未找到文件。
paddle/gserver/activations/ActivationFunction.cpp
浏览文件 @
a0a3a685
...
...
@@ -396,6 +396,44 @@ Error __must_check backward(Argument& act) {
}
END_DEFINE_ACTIVATION
(
exponential
)
/**
* @brief Reciprocal Activation.
* \f[
* f(z) = 1/z
* \f]
*/
BEGIN_DEFINE_ACTIVATION
(
reciprocal
)
Error
__must_check
forward
(
Argument
&
act
)
{
act
.
value
->
reciprocal2
();
return
Error
();
}
Error
__must_check
backward
(
Argument
&
act
)
{
act
.
grad
->
dotMulSquare
(
*
act
.
value
);
act
.
grad
->
neg
();
return
Error
();
}
END_DEFINE_ACTIVATION
(
reciprocal
)
/**
* @brief Square Root Activation.
* \f[
* f(z) = sqrt(z)
* \f]
*/
BEGIN_DEFINE_ACTIVATION
(
sqrt
)
Error
__must_check
forward
(
Argument
&
act
)
{
act
.
value
->
sqrt2
();
return
Error
();
}
Error
__must_check
backward
(
Argument
&
act
)
{
act
.
grad
->
dotDiv
(
*
act
.
grad
,
*
act
.
value
);
act
.
grad
->
mulScalar
(
0.5
);
return
Error
();
}
END_DEFINE_ACTIVATION
(
sqrt
)
/**
* @brief Logarithm Activation.
* \f[
...
...
python/paddle/trainer_config_helpers/activations.py
浏览文件 @
a0a3a685
...
...
@@ -17,7 +17,7 @@ __all__ = [
"IdentityActivation"
,
"LinearActivation"
,
'SequenceSoftmaxActivation'
,
'ExpActivation'
,
"ReluActivation"
,
"BReluActivation"
,
"SoftReluActivation"
,
"STanhActivation"
,
"AbsActivation"
,
"SquareActivation"
,
"BaseActivation"
,
"LogActivation"
"LogActivation"
,
"SqrtActivation"
,
"ReciprocalActivation"
]
...
...
@@ -224,3 +224,27 @@ class LogActivation(BaseActivation):
def
__init__
(
self
):
BaseActivation
.
__init__
(
self
,
'log'
,
False
)
class
SqrtActivation
(
BaseActivation
):
"""
Square Root Activation.
.. math::
f(z) = sqrt(z)
"""
def
__init__
(
self
):
BaseActivation
.
__init__
(
self
,
'sqrt'
,
False
)
class
ReciprocalActivation
(
BaseActivation
):
"""
Reciprocal Activation.
.. math::
f(z) = 1/z
"""
def
__init__
(
self
):
BaseActivation
.
__init__
(
self
,
'reciprocal'
,
False
)
python/paddle/trainer_config_helpers/layer_math.py
浏览文件 @
a0a3a685
...
...
@@ -40,6 +40,8 @@ register_unary_math_op('sigmoid', act.SigmoidActivation())
register_unary_math_op
(
'tanh'
,
act
.
TanhActivation
())
register_unary_math_op
(
'square'
,
act
.
SquareActivation
())
register_unary_math_op
(
'relu'
,
act
.
ReluActivation
())
register_unary_math_op
(
'sqrt'
,
act
.
SqrtActivation
())
register_unary_math_op
(
'reciprocal'
,
act
.
ReciprocalActivation
())
def
add
(
layeroutput
,
other
):
...
...
python/paddle/trainer_config_helpers/tests/configs/math_ops.py
浏览文件 @
a0a3a685
...
...
@@ -4,6 +4,8 @@ settings(batch_size=1000, learning_rate=1e-5)
x
=
data_layer
(
name
=
'data'
,
size
=
100
)
x
=
layer_math
.
exp
(
x
)
x
=
layer_math
.
sqrt
(
x
)
x
=
layer_math
.
reciprocal
(
x
)
x
=
layer_math
.
log
(
x
)
x
=
layer_math
.
abs
(
x
)
x
=
layer_math
.
sigmoid
(
x
)
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr
浏览文件 @
a0a3a685
...
...
@@ -20,13 +20,43 @@ layers {
}
}
}
layers {
name: "__sqrt_0__"
type: "mixed"
size: 100
active_type: "sqrt"
inputs {
input_layer_name: "__exp_0__"
proj_conf {
type: "identity"
name: "___sqrt_0__.w0"
input_size: 100
output_size: 100
}
}
}
layers {
name: "__reciprocal_0__"
type: "mixed"
size: 100
active_type: "reciprocal"
inputs {
input_layer_name: "__sqrt_0__"
proj_conf {
type: "identity"
name: "___reciprocal_0__.w0"
input_size: 100
output_size: 100
}
}
}
layers {
name: "__log_0__"
type: "mixed"
size: 100
active_type: "log"
inputs {
input_layer_name: "__
exp
_0__"
input_layer_name: "__
reciprocal
_0__"
proj_conf {
type: "identity"
name: "___log_0__.w0"
...
...
@@ -351,6 +381,8 @@ sub_models {
name: "root"
layer_names: "data"
layer_names: "__exp_0__"
layer_names: "__sqrt_0__"
layer_names: "__reciprocal_0__"
layer_names: "__log_0__"
layer_names: "__abs_0__"
layer_names: "__sigmoid_0__"
...
...
python/paddle/v2/trainer.py
浏览文件 @
a0a3a685
...
...
@@ -177,7 +177,7 @@ class SGD(object):
Testing method. Will test input data.
:param reader: A reader that reads and yeilds data items.
:type reader: collections.Iterable
:type reader: collections.Iterable
:param feeding: Feeding is a map of neural network input name and array
index that reader returns.
:type feeding: dict
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录