提交 b1c081f4 编写于 作者: Z zhongpu 提交者: hong

polish Optimizer's API description, test=develop (#22314)

上级 008ea1ae
......@@ -123,7 +123,11 @@ class Optimizer(object):
.. code-block:: python
import paddle.fluid as fluid
adam = fluid.optimizer.Adam(0.001)
with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])
adam = fluid.optimizer.Adam(0.001, parameter_list=emb.parameters())
state_dict = adam.state_dict()
'''
......@@ -160,19 +164,19 @@ class Optimizer(object):
.. code-block:: python
with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding( "emb", [10, 10])
emb = fluid.dygraph.Embedding([10, 10])
state_dict = emb.state_dict()
fluid.save_dygraph( state_dict, "paddle_dy")
fluid.save_dygraph(state_dict, "paddle_dy")
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, "padle_dy")
fluid.save_dygraph(state_dict, "paddle_dy")
para_state_dict, opti_state_dict = fluid.load_dygraph( "paddle_dy")
adam.set_dict( opti_state_dict )
adam.set_dict(opti_state_dict)
'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册