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 3219e2d0490d0f7714d6fb7d2cda1103aa0f6b9c..53f77a5ce11b1cb565a61be0ec1307d9246ce2d9 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 cc28502a29d542127f03d23be3ee2cf8ad9fd6e0..25a8c0c3da803e639241935143c459fe8e6cd46d 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 528dac5988992ad5e5d0e32bf28e0c49af4fa134..783875287b3339ad2b984c5c6ceb138f013bf2e4 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