Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzpei9
Paddle
提交
fb49bc2c
P
Paddle
项目概览
wzpei9
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fb49bc2c
编写于
9月 04, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename mse_cost into square_error_cost.
上级
c1feb27f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
17 deletion
+22
-17
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+17
-12
python/paddle/trainer_config_helpers/tests/configs/protostr/test_cost_layers_with_weight.protostr
...ts/configs/protostr/test_cost_layers_with_weight.protostr
+4
-4
python/paddle/trainer_config_helpers/tests/configs/test_cost_layers_with_weight.py
...fig_helpers/tests/configs/test_cost_layers_with_weight.py
+1
-1
未找到文件。
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
fb49bc2c
...
...
@@ -53,7 +53,7 @@ __all__ = [
'cos_sim'
,
'hsigmoid'
,
'conv_projection'
,
'
mse
_cost'
,
'
square_error
_cost'
,
'regression_cost'
,
'classification_cost'
,
'LayerOutput'
,
...
...
@@ -4238,13 +4238,18 @@ def __cost_input__(input, label, weight=None):
@
wrap_name_default
()
@
layer_support
()
def
mse_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
coeff
=
1.0
,
layer_attr
=
None
):
def
square_error_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
coeff
=
1.0
,
layer_attr
=
None
):
"""
mean squared
error cost:
sum of square
error cost:
.. math::
\\
frac{1}{N}
\sum_{i=1}^N(t_i-y_i)^2
cost =
\
\
sum_{i=1}^N(t_i-y_i)^2
:param name: layer name.
:type name: basestring
...
...
@@ -4273,7 +4278,7 @@ def mse_cost(input, label, weight=None, name=None, coeff=1.0, layer_attr=None):
return
LayerOutput
(
name
,
LayerType
.
COST
,
parents
=
parents
,
size
=
1
)
regression_cost
=
mse
_cost
regression_cost
=
square_error
_cost
@
wrap_name_default
(
"cost"
)
...
...
@@ -5798,9 +5803,9 @@ def huber_regression_cost(input,
coeff
=
1.0
,
layer_attr
=
None
):
"""
In statistics, the Huber loss is a loss function used in robust regression,
that is less sensitive to outliers in data than the squared error loss.
Given a prediction f(x), a label y and :math:`\delta`, the loss function
In statistics, the Huber loss is a loss function used in robust regression,
that is less sensitive to outliers in data than the squared error loss.
Given a prediction f(x), a label y and :math:`\delta`, the loss function
is defined as:
.. math:
...
...
@@ -5848,13 +5853,13 @@ def huber_classification_cost(input,
coeff
=
1.0
,
layer_attr
=
None
):
"""
For classification purposes, a variant of the Huber loss called modified Huber
is sometimes used. Given a prediction f(x) (a real-valued classifier score) and
a true binary class label :math:`y\in \left \{-1, 1
\r
ight \}`, the modified Huber
For classification purposes, a variant of the Huber loss called modified Huber
is sometimes used. Given a prediction f(x) (a real-valued classifier score) and
a true binary class label :math:`y\in \left \{-1, 1
\r
ight \}`, the modified Huber
loss is defined as:
.. math:
loss = \max \left ( 0, 1-yf(x)
\r
ight )^2, yf(x)\geq 1
loss = \max \left ( 0, 1-yf(x)
\r
ight )^2, yf(x)\geq 1
loss = -4yf(x),
\t
ext{otherwise}
The example usage is:
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_cost_layers_with_weight.protostr
浏览文件 @
fb49bc2c
...
...
@@ -45,7 +45,7 @@ layers {
coeff: 1.0
}
layers {
name: "__
mse
_cost_0__"
name: "__
square_error
_cost_0__"
type: "square_error"
size: 1
active_type: ""
...
...
@@ -130,7 +130,7 @@ input_layer_names: "label"
input_layer_names: "weight"
input_layer_names: "multi_class_label"
output_layer_names: "__cost_0__"
output_layer_names: "__
mse
_cost_0__"
output_layer_names: "__
square_error
_cost_0__"
output_layer_names: "__nce_layer_0__"
evaluators {
name: "classification_error_evaluator"
...
...
@@ -146,7 +146,7 @@ sub_models {
layer_names: "weight"
layer_names: "__fc_layer_0__"
layer_names: "__cost_0__"
layer_names: "__
mse
_cost_0__"
layer_names: "__
square_error
_cost_0__"
layer_names: "multi_class_label"
layer_names: "__nce_layer_0__"
input_layer_names: "input"
...
...
@@ -154,7 +154,7 @@ sub_models {
input_layer_names: "weight"
input_layer_names: "multi_class_label"
output_layer_names: "__cost_0__"
output_layer_names: "__
mse
_cost_0__"
output_layer_names: "__
square_error
_cost_0__"
output_layer_names: "__nce_layer_0__"
evaluator_names: "classification_error_evaluator"
is_recurrent_layer_group: false
...
...
python/paddle/trainer_config_helpers/tests/configs/test_cost_layers_with_weight.py
浏览文件 @
fb49bc2c
...
...
@@ -10,7 +10,7 @@ fc = fc_layer(input=data, size=10, act=SoftmaxActivation())
outputs
(
classification_cost
(
input
=
fc
,
label
=
lbl
,
weight
=
wt
),
mse
_cost
(
square_error
_cost
(
input
=
fc
,
label
=
lbl
,
weight
=
wt
),
nce_layer
(
input
=
fc
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录