Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7dbc77ba
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7dbc77ba
编写于
3月 17, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename regression_cost to mse_cost
上级
56fcf9c1
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
34 addition
and
29 deletion
+34
-29
demo/introduction/api_train_v2.py
demo/introduction/api_train_v2.py
+1
-1
demo/introduction/trainer_config.py
demo/introduction/trainer_config.py
+1
-1
demo/recommendation/api_train_v2.py
demo/recommendation/api_train_v2.py
+1
-1
demo/recommendation/trainer_config.py
demo/recommendation/trainer_config.py
+1
-4
doc/api/v1/trainer_config_helpers/layers.rst
doc/api/v1/trainer_config_helpers/layers.rst
+12
-6
doc/getstarted/basic_usage/index_cn.rst
doc/getstarted/basic_usage/index_cn.rst
+2
-2
doc/getstarted/basic_usage/index_en.rst
doc/getstarted/basic_usage/index_en.rst
+1
-1
doc/howto/usage/k8s/k8s_distributed_cn.md
doc/howto/usage/k8s/k8s_distributed_cn.md
+1
-1
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+7
-4
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/v2/tests/test_layer.py
python/paddle/v2/tests/test_layer.py
+2
-3
未找到文件。
demo/introduction/api_train_v2.py
浏览文件 @
7dbc77ba
...
@@ -14,7 +14,7 @@ def main():
...
@@ -14,7 +14,7 @@ def main():
act
=
paddle
.
activation
.
Linear
(),
act
=
paddle
.
activation
.
Linear
(),
bias_attr
=
paddle
.
attr
.
Param
(
name
=
'b'
))
bias_attr
=
paddle
.
attr
.
Param
(
name
=
'b'
))
y
=
paddle
.
layer
.
data
(
name
=
'y'
,
type
=
paddle
.
data_type
.
dense_vector
(
1
))
y
=
paddle
.
layer
.
data
(
name
=
'y'
,
type
=
paddle
.
data_type
.
dense_vector
(
1
))
cost
=
paddle
.
layer
.
regression
_cost
(
input
=
y_predict
,
label
=
y
)
cost
=
paddle
.
layer
.
mse
_cost
(
input
=
y_predict
,
label
=
y
)
# create parameters
# create parameters
parameters
=
paddle
.
parameters
.
create
(
cost
)
parameters
=
paddle
.
parameters
.
create
(
cost
)
...
...
demo/introduction/trainer_config.py
浏览文件 @
7dbc77ba
...
@@ -34,5 +34,5 @@ y_predict = fc_layer(
...
@@ -34,5 +34,5 @@ y_predict = fc_layer(
size
=
1
,
size
=
1
,
act
=
LinearActivation
(),
act
=
LinearActivation
(),
bias_attr
=
ParamAttr
(
name
=
'b'
))
bias_attr
=
ParamAttr
(
name
=
'b'
))
cost
=
regression
_cost
(
input
=
y_predict
,
label
=
y
)
cost
=
mse
_cost
(
input
=
y_predict
,
label
=
y
)
outputs
(
cost
)
outputs
(
cost
)
demo/recommendation/api_train_v2.py
浏览文件 @
7dbc77ba
...
@@ -61,7 +61,7 @@ def main():
...
@@ -61,7 +61,7 @@ def main():
inference
=
paddle
.
layer
.
cos_sim
(
inference
=
paddle
.
layer
.
cos_sim
(
a
=
usr_combined_features
,
b
=
mov_combined_features
,
size
=
1
,
scale
=
5
)
a
=
usr_combined_features
,
b
=
mov_combined_features
,
size
=
1
,
scale
=
5
)
cost
=
paddle
.
layer
.
regression
_cost
(
cost
=
paddle
.
layer
.
mse
_cost
(
input
=
inference
,
input
=
inference
,
label
=
paddle
.
layer
.
data
(
label
=
paddle
.
layer
.
data
(
name
=
'score'
,
type
=
paddle
.
data_type
.
dense_vector
(
1
)))
name
=
'score'
,
type
=
paddle
.
data_type
.
dense_vector
(
1
)))
...
...
demo/recommendation/trainer_config.py
浏览文件 @
7dbc77ba
...
@@ -86,10 +86,7 @@ movie_feature = construct_feature("movie")
...
@@ -86,10 +86,7 @@ movie_feature = construct_feature("movie")
user_feature
=
construct_feature
(
"user"
)
user_feature
=
construct_feature
(
"user"
)
similarity
=
cos_sim
(
a
=
movie_feature
,
b
=
user_feature
)
similarity
=
cos_sim
(
a
=
movie_feature
,
b
=
user_feature
)
if
not
is_predict
:
if
not
is_predict
:
outputs
(
outputs
(
mse_cost
(
input
=
similarity
,
label
=
data_layer
(
'rating'
,
size
=
1
)))
regression_cost
(
input
=
similarity
,
label
=
data_layer
(
'rating'
,
size
=
1
)))
define_py_data_sources2
(
define_py_data_sources2
(
'data/train.list'
,
'data/train.list'
,
...
...
doc/api/v1/trainer_config_helpers/layers.rst
浏览文件 @
7dbc77ba
...
@@ -432,6 +432,12 @@ multi_binary_label_cross_entropy
...
@@ -432,6 +432,12 @@ multi_binary_label_cross_entropy
:members: multi_binary_label_cross_entropy
:members: multi_binary_label_cross_entropy
:noindex:
:noindex:
mse_cost
---------
.. automodule:: paddle.trainer_config_helpers.layers
:members: mse_cost
:noindex:
huber_cost
huber_cost
----------
----------
.. automodule:: paddle.trainer_config_helpers.layers
.. automodule:: paddle.trainer_config_helpers.layers
...
@@ -450,6 +456,12 @@ rank_cost
...
@@ -450,6 +456,12 @@ rank_cost
:members: rank_cost
:members: rank_cost
:noindex:
:noindex:
sum_cost
---------
.. automodule:: paddle.trainer_config_helpers.layers
:members: sum_cost
:noindex:
crf_layer
crf_layer
-----------------
-----------------
.. automodule:: paddle.trainer_config_helpers.layers
.. automodule:: paddle.trainer_config_helpers.layers
...
@@ -486,12 +498,6 @@ hsigmoid
...
@@ -486,12 +498,6 @@ hsigmoid
:members: hsigmoid
:members: hsigmoid
:noindex:
:noindex:
sum_cost
---------
.. automodule:: paddle.trainer_config_helpers.layers
:members: sum_cost
:noindex:
Check Layer
Check Layer
============
============
...
...
doc/getstarted/basic_usage/index_cn.rst
浏览文件 @
7dbc77ba
...
@@ -55,7 +55,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
...
@@ -55,7 +55,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
# 线性计算网络层: ȳ = wx + b
# 线性计算网络层: ȳ = wx + b
ȳ = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
ȳ = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
# 计算误差函数,即 ȳ 和真实 y 之间的距离
# 计算误差函数,即 ȳ 和真实 y 之间的距离
cost =
regression
_cost(input= ȳ, label=y)
cost =
mse
_cost(input= ȳ, label=y)
outputs(cost)
outputs(cost)
...
@@ -69,7 +69,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
...
@@ -69,7 +69,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
- **数据层**:数据层 `data_layer` 是神经网络的入口,它读入数据并将它们传输到接下来的网络层。这里数据层有两个,分别对应于变量 `x` 和 `y`。
- **数据层**:数据层 `data_layer` 是神经网络的入口,它读入数据并将它们传输到接下来的网络层。这里数据层有两个,分别对应于变量 `x` 和 `y`。
- **全连接层**:全连接层 `fc_layer` 是基础的计算单元,这里利用它建模变量之间的线性关系。计算单元是神经网络的核心,PaddlePaddle支持大量的计算单元和任意深度的网络连接,从而可以拟合任意的函数来学习复杂的数据关系。
- **全连接层**:全连接层 `fc_layer` 是基础的计算单元,这里利用它建模变量之间的线性关系。计算单元是神经网络的核心,PaddlePaddle支持大量的计算单元和任意深度的网络连接,从而可以拟合任意的函数来学习复杂的数据关系。
- **回归误差代价层**:回归误差代价层 `
regression
_cost` 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。
- **回归误差代价层**:回归误差代价层 `
mse
_cost` 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。
定义了网络结构并保存为 `trainer_config.py` 之后,运行以下训练命令:
定义了网络结构并保存为 `trainer_config.py` 之后,运行以下训练命令:
...
...
doc/getstarted/basic_usage/index_en.rst
浏览文件 @
7dbc77ba
...
@@ -49,7 +49,7 @@ To recover this relationship between ``X`` and ``Y``, we use a neural network wi
...
@@ -49,7 +49,7 @@ To recover this relationship between ``X`` and ``Y``, we use a neural network wi
x = data_layer(name='x', size=1)
x = data_layer(name='x', size=1)
y = data_layer(name='y', size=1)
y = data_layer(name='y', size=1)
y_predict = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
y_predict = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
cost =
regression
_cost(input=y_predict, label=y)
cost =
mse
_cost(input=y_predict, label=y)
outputs(cost)
outputs(cost)
Some of the most fundamental usages of PaddlePaddle are demonstrated:
Some of the most fundamental usages of PaddlePaddle are demonstrated:
...
...
doc/howto/usage/k8s/k8s_distributed_cn.md
浏览文件 @
7dbc77ba
...
@@ -213,7 +213,7 @@ I1116 09:10:17.123440 50 Util.cpp:130] Calling runInitFunctions
...
@@ -213,7 +213,7 @@ I1116 09:10:17.123440 50 Util.cpp:130] Calling runInitFunctions
I1116 09:10:17.123764 50 Util.cpp:143] Call runInitFunctions
done
.
I1116 09:10:17.123764 50 Util.cpp:143] Call runInitFunctions
done
.
[
WARNING 2016-11-16 09:10:17,227 default_decorators.py:40] please use keyword arguments
in
paddle config.
[
WARNING 2016-11-16 09:10:17,227 default_decorators.py:40] please use keyword arguments
in
paddle config.
[
INFO 2016-11-16 09:10:17,239 networks.py:1282] The input order is
[
movie_id, title, genres, user_id, gender, age, occupation, rating]
[
INFO 2016-11-16 09:10:17,239 networks.py:1282] The input order is
[
movie_id, title, genres, user_id, gender, age, occupation, rating]
[
INFO 2016-11-16 09:10:17,239 networks.py:1289] The output order is
[
__
regression
_cost_0__]
[
INFO 2016-11-16 09:10:17,239 networks.py:1289] The output order is
[
__
mse
_cost_0__]
I1116 09:10:17.392917 50 Trainer.cpp:170] trainer mode: Normal
I1116 09:10:17.392917 50 Trainer.cpp:170] trainer mode: Normal
I1116 09:10:17.613910 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
I1116 09:10:17.613910 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
I1116 09:10:17.680917 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
I1116 09:10:17.680917 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
7dbc77ba
...
@@ -52,7 +52,7 @@ __all__ = [
...
@@ -52,7 +52,7 @@ __all__ = [
"cos_sim"
,
"cos_sim"
,
"hsigmoid"
,
"hsigmoid"
,
"conv_projection"
,
"conv_projection"
,
"
regression
_cost"
,
"
mse
_cost"
,
'classification_cost'
,
'classification_cost'
,
"LayerOutput"
,
"LayerOutput"
,
'img_conv_layer'
,
'img_conv_layer'
,
...
@@ -3572,11 +3572,14 @@ def __cost_input__(input, label, weight=None):
...
@@ -3572,11 +3572,14 @@ def __cost_input__(input, label, weight=None):
@
wrap_name_default
()
@
wrap_name_default
()
@
layer_support
()
@
layer_support
()
def
regression
_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
layer_attr
=
None
):
def
mse
_cost
(
input
,
label
,
weight
=
None
,
name
=
None
,
layer_attr
=
None
):
"""
"""
Regression Layer.
mean squared error cost:
.. math::
$
\f
rac{1}{N}\sum_{i=1}^N(t _i- y_i)^2$
TODO(yuyang18): Complete this method.
:param name: layer name.
:param name: layer name.
:type name: basestring
:type name: basestring
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_cost_layers_with_weight.protostr
浏览文件 @
7dbc77ba
...
@@ -45,7 +45,7 @@ layers {
...
@@ -45,7 +45,7 @@ layers {
coeff: 1.0
coeff: 1.0
}
}
layers {
layers {
name: "__
regression
_cost_0__"
name: "__
mse
_cost_0__"
type: "square_error"
type: "square_error"
size: 1
size: 1
active_type: ""
active_type: ""
...
@@ -84,7 +84,7 @@ input_layer_names: "input"
...
@@ -84,7 +84,7 @@ input_layer_names: "input"
input_layer_names: "label"
input_layer_names: "label"
input_layer_names: "weight"
input_layer_names: "weight"
output_layer_names: "__cost_0__"
output_layer_names: "__cost_0__"
output_layer_names: "__
regression
_cost_0__"
output_layer_names: "__
mse
_cost_0__"
evaluators {
evaluators {
name: "classification_error_evaluator"
name: "classification_error_evaluator"
type: "classification_error"
type: "classification_error"
...
@@ -99,12 +99,12 @@ sub_models {
...
@@ -99,12 +99,12 @@ sub_models {
layer_names: "weight"
layer_names: "weight"
layer_names: "__fc_layer_0__"
layer_names: "__fc_layer_0__"
layer_names: "__cost_0__"
layer_names: "__cost_0__"
layer_names: "__
regression
_cost_0__"
layer_names: "__
mse
_cost_0__"
input_layer_names: "input"
input_layer_names: "input"
input_layer_names: "label"
input_layer_names: "label"
input_layer_names: "weight"
input_layer_names: "weight"
output_layer_names: "__cost_0__"
output_layer_names: "__cost_0__"
output_layer_names: "__
regression
_cost_0__"
output_layer_names: "__
mse
_cost_0__"
evaluator_names: "classification_error_evaluator"
evaluator_names: "classification_error_evaluator"
is_recurrent_layer_group: false
is_recurrent_layer_group: false
}
}
...
...
python/paddle/trainer_config_helpers/tests/configs/test_cost_layers_with_weight.py
浏览文件 @
7dbc77ba
...
@@ -10,5 +10,5 @@ fc = fc_layer(input=data, size=10, act=SoftmaxActivation())
...
@@ -10,5 +10,5 @@ fc = fc_layer(input=data, size=10, act=SoftmaxActivation())
outputs
(
outputs
(
classification_cost
(
classification_cost
(
input
=
fc
,
label
=
lbl
,
weight
=
wt
),
input
=
fc
,
label
=
lbl
,
weight
=
wt
),
regression
_cost
(
mse
_cost
(
input
=
fc
,
label
=
lbl
,
weight
=
wt
))
input
=
fc
,
label
=
lbl
,
weight
=
wt
))
python/paddle/v2/tests/test_layer.py
浏览文件 @
7dbc77ba
...
@@ -126,9 +126,8 @@ class CostLayerTest(unittest.TestCase):
...
@@ -126,9 +126,8 @@ class CostLayerTest(unittest.TestCase):
cost3
=
layer
.
cross_entropy_cost
(
input
=
inference
,
label
=
label
)
cost3
=
layer
.
cross_entropy_cost
(
input
=
inference
,
label
=
label
)
cost4
=
layer
.
cross_entropy_with_selfnorm_cost
(
cost4
=
layer
.
cross_entropy_with_selfnorm_cost
(
input
=
inference
,
label
=
label
)
input
=
inference
,
label
=
label
)
cost5
=
layer
.
regression_cost
(
input
=
inference
,
label
=
label
)
cost5
=
layer
.
mse_cost
(
input
=
inference
,
label
=
label
)
cost6
=
layer
.
regression_cost
(
cost6
=
layer
.
mse_cost
(
input
=
inference
,
label
=
label
,
weight
=
weight
)
input
=
inference
,
label
=
label
,
weight
=
weight
)
cost7
=
layer
.
multi_binary_label_cross_entropy_cost
(
cost7
=
layer
.
multi_binary_label_cross_entropy_cost
(
input
=
inference
,
label
=
label
)
input
=
inference
,
label
=
label
)
cost8
=
layer
.
rank_cost
(
left
=
score
,
right
=
score
,
label
=
score
)
cost8
=
layer
.
rank_cost
(
left
=
score
,
right
=
score
,
label
=
score
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录