From a0ea568467cf6da0432ecd3e1f4460bf57cfb5a6 Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Thu, 18 Jun 2020 17:04:48 +0800 Subject: [PATCH] fix sample code error of API,test=develop (#2217) --- doc/fluid/api_cn/dygraph_cn/NaturalExpDecay_cn.rst | 10 ++++++---- doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/fluid/api_cn/dygraph_cn/NaturalExpDecay_cn.rst b/doc/fluid/api_cn/dygraph_cn/NaturalExpDecay_cn.rst index 5aa06002b..ddd88bb92 100644 --- a/doc/fluid/api_cn/dygraph_cn/NaturalExpDecay_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/NaturalExpDecay_cn.rst @@ -50,12 +50,14 @@ NaturalExpDecay import paddle.fluid as fluid base_lr = 0.1 with fluid.dygraph.guard(): + emb = fluid.dygraph.Embedding([10, 10]) sgd_optimizer = fluid.optimizer.SGD( learning_rate=fluid.dygraph.NaturalExpDecay( - learning_rate=base_lr, - decay_steps=10000, - decay_rate=0.5, - staircase=True)) + learning_rate=base_lr, + decay_steps=10000, + decay_rate=0.5, + staircase=True), + parameter_list=emb.parameters()) diff --git a/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst b/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst index 2992d5501..7c8261789 100644 --- a/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst @@ -30,9 +30,13 @@ load_dygraph with fluid.dygraph.guard(): emb = fluid.dygraph.Embedding([10, 10]) + state_dict = emb.state_dict() fluid.save_dygraph( state_dict, "paddle_dy") - adam = fluid.optimizer.Adam( learning_rate = fluid.layers.noam_decay( 100, 10000) ) + + adam = fluid.optimizer.Adam( learning_rate = fluid.layers.noam_decay( 100, 10000), + parameter_list = emb.parameters() ) + state_dict = adam.state_dict() fluid.save_dygraph( state_dict, "paddle_dy") -- GitLab