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

fix sample code error of API,test=develop (#2217)

上级 5d848075
...@@ -50,12 +50,14 @@ NaturalExpDecay ...@@ -50,12 +50,14 @@ NaturalExpDecay
import paddle.fluid as fluid import paddle.fluid as fluid
base_lr = 0.1 base_lr = 0.1
with fluid.dygraph.guard(): with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10])
sgd_optimizer = fluid.optimizer.SGD( sgd_optimizer = fluid.optimizer.SGD(
learning_rate=fluid.dygraph.NaturalExpDecay( learning_rate=fluid.dygraph.NaturalExpDecay(
learning_rate=base_lr, learning_rate=base_lr,
decay_steps=10000, decay_steps=10000,
decay_rate=0.5, decay_rate=0.5,
staircase=True)) staircase=True),
parameter_list=emb.parameters())
......
...@@ -30,9 +30,13 @@ load_dygraph ...@@ -30,9 +30,13 @@ load_dygraph
with fluid.dygraph.guard(): with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding([10, 10]) emb = fluid.dygraph.Embedding([10, 10])
state_dict = emb.state_dict() 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) )
adam = fluid.optimizer.Adam( learning_rate = fluid.layers.noam_decay( 100, 10000),
parameter_list = emb.parameters() )
state_dict = adam.state_dict() state_dict = adam.state_dict()
fluid.save_dygraph( state_dict, "paddle_dy") fluid.save_dygraph( state_dict, "paddle_dy")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册