未验证 提交 ed9d59cd 编写于 作者: Z zhouwei25 提交者: GitHub

fix save_dygraph cn doc error and sample code error,test=develop (#1767)

fix save_dygraph cn doc error and sample code error
上级 42108fb0
......@@ -12,7 +12,7 @@ save_dygraph
注: ``model_path`` 不可以是一个目录。
该接口会根据 ``state_dict`` 的内容,自动给 ``model_path`` 添加 ``.pdparams`` 或者 ``.pdopt`` 后缀,
生成 ``model_path + ".pdparms"`` 或者 ``model_path + ".pdopt"`` 文件。
生成 ``model_path + ".pdparams"`` 或者 ``model_path + ".pdopt"`` 文件。
参数:
- **state_dict** (dict of Parameters) – 要保存的模型参数的 ``dict`` 。
......@@ -27,17 +27,15 @@ save_dygraph
import paddle.fluid as fluid
with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])
emb = fluid.dygraph.Embedding(
size=[10, 32],
param_attr='emb.w',
is_sparse=False)
state_dict = emb.state_dict()
fluid.save_dygraph(state_dict, "paddle_dy") # 会保存为 paddle_dy.pdparams
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") # 会保存为 paddle_dy.pdopt
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册