Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Aug 27, 2020
1 parent 8dc8d44 commit 4ce448a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def testLoadAndSetVarBase(self):
adam._learning_rate.step_num = 0

para_state_dict, opti_state_dict = paddle.load("./test_dy")
print(opti_state_dict)
adam.set_dict(opti_state_dict)

opti_dict = adam.state_dict()
Expand Down
14 changes: 1 addition & 13 deletions python/paddle/optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def set_state_dict(self, state_dict):
state_dict = emb.state_dict()
paddle.framework.save(state_dict, "paddle_dy")
adam = paddle.optimizer.Adam(learning_rate=paddle.nn.functional.noam_decay( 100, 10000),
adam = paddle.optimizer.Adam(learning_rate=paddle.optimizer.NoamLR( 100, 10000),
parameters=emb.parameters())
state_dict = adam.state_dict()
paddle.framework.save(state_dict, "paddle_dy")
Expand Down Expand Up @@ -327,18 +327,6 @@ def set_lr(self, value):
# current lr is 0.5
# current lr is 0.6
# set learning rate manually by framework Tensor
lr_var = paddle.create_global_var(
shape=[1], value=0.7, dtype='float32')
adam.set_lr(lr_var)
lr = adam.get_lr()
print("current lr is {}".format(lr))
# Print:
# current lr is 0.7
"""
if not isinstance(value, (int, float)):
raise TypeError(
Expand Down

0 comments on commit 4ce448a

Please sign in to comment.