Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
87cb840c
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
87cb840c
编写于
5月 15, 2017
作者:
P
Peng Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add coeff parameter to the helpers of mse_cost, crf_layer and smooth_l1_cost
上级
2e527ad3
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
12 addition
and
2 deletion
+12
-2
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+12
-2
未找到文件。
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
87cb840c
...
...
@@ -3765,7 +3765,7 @@ def __cost_input__(input, label, weight=None):
@
wrap_name_default
()
@
layer_support
()
def
mse_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
layer_attr
=
None
):
def
mse_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
coeff
=
1.0
,
layer_attr
=
None
):
"""
mean squared error cost:
...
...
@@ -3782,6 +3782,8 @@ def mse_cost(input, label, weight=None, name=None, layer_attr=None):
:param weight: The weight affects the cost, namely the scale of cost.
It is an optional argument.
:type weight: LayerOutput
:param coeff: The coefficient affects the gradient in the backward.
:type coeff: float
:param layer_attr: layer's extra attribute.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
...
...
@@ -3793,6 +3795,7 @@ def mse_cost(input, label, weight=None, name=None, layer_attr=None):
inputs
=
ipts
,
type
=
"square_error"
,
name
=
name
,
coeff
=
coeff
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
return
LayerOutput
(
name
,
LayerType
.
COST
,
parents
=
parents
,
size
=
1
)
...
...
@@ -4798,6 +4801,7 @@ def crf_layer(input,
weight
=
None
,
param_attr
=
None
,
name
=
None
,
coeff
=
1.0
,
layer_attr
=
None
):
"""
A layer for calculating the cost of sequential conditional random
...
...
@@ -4824,6 +4828,8 @@ def crf_layer(input,
:type param_attr: ParameterAttribute
:param name: The name of this layers. It is not necessary.
:type name: None|basestring
:param coeff: The coefficient affects the gradient in the backward.
:type coeff: float
:param layer_attr: Extra Layer config.
:type layer_attr: ExtraLayerAttribute|None
:return: LayerOutput object.
...
...
@@ -4848,6 +4854,7 @@ def crf_layer(input,
type
=
LayerType
.
CRF_LAYER
,
size
=
size
,
inputs
=
ipts
,
coeff
=
coeff
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
parents
=
[
input
,
label
]
if
weight
is
not
None
:
...
...
@@ -5379,7 +5386,7 @@ def multi_binary_label_cross_entropy(input,
@
wrap_name_default
()
@
layer_support
()
def
smooth_l1_cost
(
input
,
label
,
name
=
None
,
layer_attr
=
None
):
def
smooth_l1_cost
(
input
,
label
,
name
=
None
,
coeff
=
1.0
,
layer_attr
=
None
):
"""
This is a L1 loss but more smooth. It requires that the
size of input and label are equal. The formula is as follows,
...
...
@@ -5408,6 +5415,8 @@ def smooth_l1_cost(input, label, name=None, layer_attr=None):
:type input: LayerOutput
:param name: The name of this layers. It is not necessary.
:type name: None|basestring
:param coeff: The coefficient affects the gradient in the backward.
:type coeff: float
:param layer_attr: Extra Layer Attribute.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
...
...
@@ -5421,6 +5430,7 @@ def smooth_l1_cost(input, label, name=None, layer_attr=None):
name
=
name
,
type
=
LayerType
.
SMOOTH_L1
,
inputs
=
[
input
.
name
,
label
.
name
],
coeff
=
coeff
,
**
ExtraLayerAttribute
.
to_kwargs
(
layer_attr
))
return
LayerOutput
(
name
,
LayerType
.
SMOOTH_L1
,
parents
=
[
input
,
label
],
size
=
1
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录