From ed056f70cc32f9d009c7e0351de2eb38aa4dcf6e Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Mon, 11 May 2020 21:24:29 +0800 Subject: [PATCH] fix the diff of sample code in chinese doc with english doc (#2038) fix the diff of sample code in chinese doc with english doc --- doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst | 3 ++- doc/fluid/api_cn/dygraph_cn/save_dygraph_cn.rst | 16 +++++++--------- doc/fluid/api_cn/fluid_cn/in_dygraph_mode_cn.rst | 10 +++++----- 3 files changed, 14 insertions(+), 15 deletions(-) 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 3219e2d04..53f77a5ce 100644 --- a/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/load_dygraph_cn.rst @@ -32,7 +32,8 @@ load_dygraph 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") diff --git a/doc/fluid/api_cn/dygraph_cn/save_dygraph_cn.rst b/doc/fluid/api_cn/dygraph_cn/save_dygraph_cn.rst index cc28502a2..25a8c0c3d 100644 --- a/doc/fluid/api_cn/dygraph_cn/save_dygraph_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/save_dygraph_cn.rst @@ -29,15 +29,13 @@ save_dygraph import paddle.fluid as fluid with fluid.dygraph.guard(): - emb = fluid.dygraph.Embedding( - size=[10, 32], - param_attr='emb.w', - is_sparse=False) + emb = fluid.dygraph.Embedding([10, 10]) + state_dict = emb.state_dict() - fluid.save_dygraph(state_dict, "paddle_dy") # 会保存为 paddle_dy.pdparams + fluid.save_dygraph( state_dict, "paddle_dy") # 会保存为 paddle_dy.pdparams + + adam = fluid.optimizer.Adam( learning_rate = fluid.layers.noam_decay( 100, 10000), + parameter_list = emb.parameters() ) - 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") # 会保存为 paddle_dy.pdopt + fluid.save_dygraph( state_dict, "paddle_dy") # 会保存为 paddle_dy.pdopt \ No newline at end of file diff --git a/doc/fluid/api_cn/fluid_cn/in_dygraph_mode_cn.rst b/doc/fluid/api_cn/fluid_cn/in_dygraph_mode_cn.rst index 528dac598..783875287 100644 --- a/doc/fluid/api_cn/fluid_cn/in_dygraph_mode_cn.rst +++ b/doc/fluid/api_cn/fluid_cn/in_dygraph_mode_cn.rst @@ -16,11 +16,11 @@ in_dygraph_mode .. code-block:: python - from __future__ import print_function import paddle.fluid as fluid - if fluid.in_dygraph_mode(): - print('running in dygraph mode') - else: - print('not running in dygraph mode') + + fluid.enable_dygraph() # 现在进入 dygragh 模式 + print(fluid.in_dygraph_mode()) # True + fluid.disable_dygraph() + print(fluid.in_dygraph_mode()) # False -- GitLab