未验证 提交 ed056f70 编写于 作者: Z Zhou Wei 提交者: GitHub

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
上级 68604a66
......@@ -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")
......
......@@ -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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册