提交 1865e86a 编写于 作者: N Nicky

Fix trainer error in readme due to optimizer function

上级 63b5ec3f
...@@ -142,6 +142,15 @@ def train_program(): ...@@ -142,6 +142,15 @@ def train_program():
return avg_loss return avg_loss
``` ```
### Optimizer Function 配置
在下面的 `SGD optimizer``learning_rate` 是训练的速度,与网络的训练收敛速度有关系。
```python
def optimizer_program():
return fluid.optimizer.SGD(learning_rate=0.001)
```
### 定义运算场所 ### 定义运算场所
我们可以定义运算是发生在CPU还是GPU 我们可以定义运算是发生在CPU还是GPU
...@@ -157,7 +166,7 @@ place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace() ...@@ -157,7 +166,7 @@ place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
trainer = fluid.Trainer( trainer = fluid.Trainer(
train_func=train_program, train_func=train_program,
place=place, place=place,
optimizer_func=fluid.optimizer.SGD(learning_rate=0.001)) optimizer_func=optimizer_program)
``` ```
### 开始提供数据 ### 开始提供数据
......
...@@ -149,6 +149,14 @@ def train_program(): ...@@ -149,6 +149,14 @@ def train_program():
return avg_loss return avg_loss
``` ```
### Optimizer Function Configuration
In the following `SGD` optimizer, `learning_rate` specifies the learning rate in the optimization procedure.
```python
def optimizer_program():
return fluid.optimizer.SGD(learning_rate=0.001)
```
### Specify Place ### Specify Place
Specify your training environment, you should specify if the training is on CPU or GPU. Specify your training environment, you should specify if the training is on CPU or GPU.
...@@ -165,7 +173,7 @@ The trainer will take the `train_program` as input. ...@@ -165,7 +173,7 @@ The trainer will take the `train_program` as input.
trainer = fluid.Trainer( trainer = fluid.Trainer(
train_func=train_program, train_func=train_program,
place=place, place=place,
optimizer_func=fluid.optimizer.SGD(learning_rate=0.001)) optimizer_func=optimizer_program)
``` ```
### Feeding Data ### Feeding Data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册