提交 df2ba16e 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #219 from luotao1/mse

rename regression_cost to mse_cost
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
" size=1,\n", " size=1,\n",
" act=paddle.activation.Linear())\n", " act=paddle.activation.Linear())\n",
"y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))\n", "y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))\n",
"cost = paddle.layer.regression_cost(input=y_predict, label=y)\n" "cost = paddle.layer.mse_cost(input=y_predict, label=y)\n"
], ],
"outputs": [ "outputs": [
{ {
......
...@@ -132,7 +132,7 @@ y_predict = paddle.layer.fc(input=x, ...@@ -132,7 +132,7 @@ y_predict = paddle.layer.fc(input=x,
size=1, size=1,
act=paddle.activation.Linear()) act=paddle.activation.Linear())
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
......
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
" size=1,\n", " size=1,\n",
" act=paddle.activation.Linear())\n", " act=paddle.activation.Linear())\n",
"y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))\n", "y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))\n",
"cost = paddle.layer.regression_cost(input=y_predict, label=y)\n" "cost = paddle.layer.mse_cost(input=y_predict, label=y)\n"
], ],
"outputs": [ "outputs": [
{ {
......
...@@ -126,7 +126,7 @@ y_predict = paddle.layer.fc(input=x, ...@@ -126,7 +126,7 @@ y_predict = paddle.layer.fc(input=x,
size=1, size=1,
act=paddle.activation.Linear()) act=paddle.activation.Linear())
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)
``` ```
### 创建参数 ### 创建参数
......
...@@ -174,7 +174,7 @@ y_predict = paddle.layer.fc(input=x, ...@@ -174,7 +174,7 @@ y_predict = paddle.layer.fc(input=x,
size=1, size=1,
act=paddle.activation.Linear()) act=paddle.activation.Linear())
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
......
...@@ -168,7 +168,7 @@ y_predict = paddle.layer.fc(input=x, ...@@ -168,7 +168,7 @@ y_predict = paddle.layer.fc(input=x,
size=1, size=1,
act=paddle.activation.Linear()) act=paddle.activation.Linear())
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)
``` ```
### 创建参数 ### 创建参数
......
...@@ -10,7 +10,7 @@ def main(): ...@@ -10,7 +10,7 @@ def main():
x = paddle.layer.data(name='x', type=paddle.data_type.dense_vector(13)) x = paddle.layer.data(name='x', type=paddle.data_type.dense_vector(13))
y_predict = paddle.layer.fc(input=x, size=1, act=paddle.activation.Linear()) y_predict = paddle.layer.fc(input=x, size=1, act=paddle.activation.Linear())
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)
......
...@@ -449,7 +449,7 @@ ...@@ -449,7 +449,7 @@
}, },
"source": [ "source": [
"inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5)\n", "inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5)\n",
"cost = paddle.layer.regression_cost(\n", "cost = paddle.layer.mse_cost(\n",
" input=inference,\n", " input=inference,\n",
" label=paddle.layer.data(\n", " label=paddle.layer.data(\n",
" name='score', type=paddle.data_type.dense_vector(1)))\n" " name='score', type=paddle.data_type.dense_vector(1)))\n"
...@@ -536,7 +536,7 @@ ...@@ -536,7 +536,7 @@
"\n", "\n",
"```text\n", "```text\n",
"[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n", "[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
"[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__]\n", "[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]\n",
"```\n", "```\n",
"\n", "\n",
"### Training\n", "### Training\n",
......
...@@ -254,7 +254,7 @@ Finally, we can use cosine similarity to calculate the similarity between user c ...@@ -254,7 +254,7 @@ Finally, we can use cosine similarity to calculate the similarity between user c
```python ```python
inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5) inference = paddle.layer.cos_sim(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)))
...@@ -282,7 +282,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, ...@@ -282,7 +282,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,
```text ```text
[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]
``` ```
### Training ### Training
......
...@@ -479,7 +479,7 @@ ...@@ -479,7 +479,7 @@
"editable": true "editable": true
}, },
"source": [ "source": [
"cost = paddle.layer.regression_cost(\n", "cost = paddle.layer.mse_cost(\n",
" input=inference,\n", " input=inference,\n",
" label=paddle.layer.data(\n", " label=paddle.layer.data(\n",
" name='score', type=paddle.data_type.dense_vector(1)))\n" " name='score', type=paddle.data_type.dense_vector(1)))\n"
...@@ -535,7 +535,7 @@ ...@@ -535,7 +535,7 @@
"source": [ "source": [
"\n", "\n",
" [INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n", " [INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
" [INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__regression_cost_0__]\n", " [INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__mse_cost_0__]\n",
"\n", "\n",
"\n", "\n",
"`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。\n", "`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。\n",
...@@ -603,7 +603,7 @@ ...@@ -603,7 +603,7 @@
"source": [ "source": [
"\n", "\n",
" [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n", " [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]\n",
" [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__]\n", " [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]\n",
"\n", "\n",
"\n", "\n",
"### 训练\n", "### 训练\n",
......
...@@ -268,7 +268,7 @@ inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_feature ...@@ -268,7 +268,7 @@ inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_feature
```python ```python
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)))
...@@ -287,7 +287,7 @@ parameters = paddle.parameters.create(cost) ...@@ -287,7 +287,7 @@ parameters = paddle.parameters.create(cost)
``` ```
[INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__mse_cost_0__]
`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。 `parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。
...@@ -311,7 +311,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, ...@@ -311,7 +311,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,
``` ```
[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]
### 训练 ### 训练
......
...@@ -296,7 +296,7 @@ Finally, we can use cosine similarity to calculate the similarity between user c ...@@ -296,7 +296,7 @@ Finally, we can use cosine similarity to calculate the similarity between user c
```python ```python
inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_features, size=1, scale=5) inference = paddle.layer.cos_sim(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)))
...@@ -324,7 +324,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, ...@@ -324,7 +324,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,
```text ```text
[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]
``` ```
### Training ### Training
......
...@@ -310,7 +310,7 @@ inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_feature ...@@ -310,7 +310,7 @@ inference = paddle.layer.cos_sim(a=usr_combined_features, b=mov_combined_feature
```python ```python
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)))
...@@ -329,7 +329,7 @@ parameters = paddle.parameters.create(cost) ...@@ -329,7 +329,7 @@ parameters = paddle.parameters.create(cost)
``` ```
[INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,284 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,287 networks.py:1478] The output order is [__mse_cost_0__]
`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。 `parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。
...@@ -353,7 +353,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters, ...@@ -353,7 +353,7 @@ trainer = paddle.trainer.SGD(cost=cost, parameters=parameters,
``` ```
[INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score] [INFO 2017-03-06 17:12:13,378 networks.py:1472] The input order is [user_id, gender_id, age_id, job_id, movie_id, category_id, movie_title, score]
[INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__regression_cost_0__] [INFO 2017-03-06 17:12:13,379 networks.py:1478] The output order is [__mse_cost_0__]
### 训练 ### 训练
......
...@@ -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)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册