diff --git a/doc/fluid/beginners_guide/programming_guide/programming_guide.md b/doc/fluid/beginners_guide/programming_guide/programming_guide.md index b17414a6fae90a0440ce3f8439a8a92e73bba894..14fbe554ee53fa1fc080340043fafd8655539b53 100644 --- a/doc/fluid/beginners_guide/programming_guide/programming_guide.md +++ b/doc/fluid/beginners_guide/programming_guide/programming_guide.md @@ -384,6 +384,9 @@ outs = exe.run( #定义损失函数 cost = fluid.layers.square_error_cost(input=y_predict,label=y) avg_cost = fluid.layers.mean(cost) + #定义优化方法 + sgd_optimizer = fluid.optimizer.SGD(learning_rate=0.01) + sgd_optimizer.minimize(avg_cost) #参数初始化 cpu = fluid.core.CPUPlace() exe = fluid.Executor(cpu)