Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
432f0517
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
432f0517
编写于
6月 06, 2018
作者:
W
Wang,Jeff
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the Mnist tutorial to use optimizer_func
上级
be85a58d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
10 deletion
+24
-10
02.recognize_digits/README.cn.md
02.recognize_digits/README.cn.md
+11
-4
02.recognize_digits/README.md
02.recognize_digits/README.md
+1
-1
02.recognize_digits/index.cn.html
02.recognize_digits/index.cn.html
+11
-4
02.recognize_digits/index.html
02.recognize_digits/index.html
+1
-1
未找到文件。
02.recognize_digits/README.cn.md
浏览文件 @
432f0517
...
...
@@ -139,7 +139,7 @@ PaddlePaddle在API中提供了自动加载[MNIST](http://yann.lecun.com/exdb/mni
1.
`train_program`
:指定如何从
`inference_program`
和
`标签值`
中获取
`loss`
的函数。
这是指定损失计算的地方。
1.
`optimizer`
: 配置如何最小化损失。PaddlePaddle 支持最主要的优化方法。
1.
`optimizer
_func
`
: 配置如何最小化损失。PaddlePaddle 支持最主要的优化方法。
1.
`Trainer`
:PaddlePaddle Trainer 管理由
`train_program`
和
`optimizer`
指定的训练过程。
通过
`event_handler`
回调函数,用户可以监控培训的进展。
...
...
@@ -238,6 +238,15 @@ def train_program():
# 该模型运行在单个CPU上
```
#### Optimizer Function 配置
在下面的
`Adam optimizer`
,
`learning_rate`
是训练的速度,与网络的训练收敛速度有关系。
```
python
def
optimizer_program
():
return
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
```
### 数据集 Feeders 配置
下一步,我们开始训练过程。
`paddle.dataset.movielens.train()`
和
`paddle.dataset.movielens.test()`
分别做训练和测试数据集。这两个函数各自返回一个reader——PaddlePaddle中的reader是一个Python函数,每次调用的时候返回一个Python yield generator。
...
...
@@ -259,16 +268,14 @@ test_reader = paddle.batch(
### Trainer 配置
现在,我们需要配置
`Trainer`
。
`Trainer`
需要接受训练程序
`train_program`
,
`place`
和优化器
`optimizer`
。
在下面的
`Adam optimizer`
,
`learning_rate`
是训练的速度,与网络的训练收敛速度有关系。
```
python
# 该模型运行在单个CPU上
use_cuda
=
False
# set to True if training with GPU
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
place
=
place
,
optimizer
=
optimizer
)
train_func
=
train_program
,
place
=
place
,
optimizer
_func
=
optimizer_program
)
``
`
#### Event Handler 配置
...
...
02.recognize_digits/README.md
浏览文件 @
432f0517
...
...
@@ -146,7 +146,7 @@ Here are the quick overview on the major fluid API complements.
This is where you specify the network flow.
1.
`train_program`
: A function that specify how to get avg_cost from
`inference_program`
and labels.
This is where you specify the loss calculations.
1.
`optimizer`
: Configure how to minimize the loss. Paddle supports most major optimization methods.
1.
`optimizer
_func
`
: Configure how to minimize the loss. Paddle supports most major optimization methods.
1.
`Trainer`
: Fluid trainer manages the training process specified by the
`train_program`
and
`optimizer`
. Users can monitor the training
progress through the
`event_handler`
callback function.
1.
`Inferencer`
: Fluid inferencer loads the
`inference_program`
and the parameters trained by the Trainer.
...
...
02.recognize_digits/index.cn.html
浏览文件 @
432f0517
...
...
@@ -181,7 +181,7 @@ PaddlePaddle在API中提供了自动加载[MNIST](http://yann.lecun.com/exdb/mni
1. `train_program`:指定如何从 `inference_program` 和`标签值`中获取 `loss` 的函数。
这是指定损失计算的地方。
1. `optimizer`: 配置如何最小化损失。PaddlePaddle 支持最主要的优化方法。
1. `optimizer
_func
`: 配置如何最小化损失。PaddlePaddle 支持最主要的优化方法。
1. `Trainer`:PaddlePaddle Trainer 管理由 `train_program` 和 `optimizer` 指定的训练过程。
通过 `event_handler` 回调函数,用户可以监控培训的进展。
...
...
@@ -280,6 +280,15 @@ def train_program():
# 该模型运行在单个CPU上
```
#### Optimizer Function 配置
在下面的 `Adam optimizer`,`learning_rate` 是训练的速度,与网络的训练收敛速度有关系。
```python
def optimizer_program():
return fluid.optimizer.Adam(learning_rate=0.001)
```
### 数据集 Feeders 配置
下一步,我们开始训练过程。`paddle.dataset.movielens.train()`和`paddle.dataset.movielens.test()`分别做训练和测试数据集。这两个函数各自返回一个reader——PaddlePaddle中的reader是一个Python函数,每次调用的时候返回一个Python yield generator。
...
...
@@ -301,16 +310,14 @@ test_reader = paddle.batch(
### Trainer 配置
现在,我们需要配置 `Trainer`。`Trainer` 需要接受训练程序 `train_program`, `place` 和优化器 `optimizer`。
在下面的 `Adam optimizer`,`learning_rate` 是训练的速度,与网络的训练收敛速度有关系。
```python
# 该模型运行在单个CPU上
use_cuda = False # set to True if training with GPU
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
optimizer = fluid.optimizer.Adam(learning_rate=0.001)
trainer = fluid.Trainer(
train_func=train_program, place=place, optimizer
=optimizer
)
train_func=train_program, place=place, optimizer
_func=optimizer_program
)
```
#### Event Handler 配置
...
...
02.recognize_digits/index.html
浏览文件 @
432f0517
...
...
@@ -188,7 +188,7 @@ Here are the quick overview on the major fluid API complements.
This is where you specify the network flow.
1. `train_program`: A function that specify how to get avg_cost from `inference_program` and labels.
This is where you specify the loss calculations.
1. `optimizer`: Configure how to minimize the loss. Paddle supports most major optimization methods.
1. `optimizer
_func
`: Configure how to minimize the loss. Paddle supports most major optimization methods.
1. `Trainer`: Fluid trainer manages the training process specified by the `train_program` and `optimizer`. Users can monitor the training
progress through the `event_handler` callback function.
1. `Inferencer`: Fluid inferencer loads the `inference_program` and the parameters trained by the Trainer.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录