diff --git a/01.fit_a_line/README.cn.md b/01.fit_a_line/README.cn.md index 87ab88516317c42a6a2d63c7ae033665dac07834..936142bfbc427fa085797f2e62b136709e085405 100644 --- a/01.fit_a_line/README.cn.md +++ b/01.fit_a_line/README.cn.md @@ -142,6 +142,15 @@ def train_program(): return avg_loss ``` +### Optimizer Function 配置 + +在下面的 `SGD optimizer`,`learning_rate` 是训练的速度,与网络的训练收敛速度有关系。 + +```python +def optimizer_program(): + return fluid.optimizer.SGD(learning_rate=0.001) +``` + ### 定义运算场所 我们可以定义运算是发生在CPU还是GPU @@ -157,7 +166,7 @@ place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace() trainer = fluid.Trainer( train_func=train_program, place=place, - optimizer_func=fluid.optimizer.SGD(learning_rate=0.001)) + optimizer_func=optimizer_program) ``` ### 开始提供数据 diff --git a/01.fit_a_line/README.md b/01.fit_a_line/README.md index df624f9d31c12ded1fac62e18b220c16659621c2..e672caf1206b13b50abbd57eb2fc465fb656cce1 100644 --- a/01.fit_a_line/README.md +++ b/01.fit_a_line/README.md @@ -149,6 +149,14 @@ def train_program(): 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 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. trainer = fluid.Trainer( train_func=train_program, place=place, - optimizer_func=fluid.optimizer.SGD(learning_rate=0.001)) + optimizer_func=optimizer_program) ``` ### Feeding Data