Skip to content

Commit

Permalink
fix sample code, fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Aug 27, 2020
1 parent 4ce448a commit d5cf60e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +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)
print(opti_state_dict['LR_Scheduler'])
adam.set_dict(opti_state_dict)

opti_dict = adam.state_dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def setUp(self):
else:
self.base_opti[k] = v

fluid.save_dygraph(self.opti_dict, "./test_dy")
fluid.save_dygraph(self.opti_dict, "./test_dy_v2")

self.state_dict = ptb_model.state_dict()

Expand All @@ -294,7 +294,7 @@ def setUp(self):
np_t = v.numpy()
self.model_base[k] = np_t

paddle.save(self.state_dict, "./test_dy")
paddle.save(self.state_dict, "./test_dy_v2")

def testLoadAndSetVarBase(self):
seed = 90
Expand Down Expand Up @@ -373,7 +373,7 @@ def testLoadAndSetVarBase(self):

self.assertTrue(np.sum(np.abs(v.numpy())) == 0)

para_state_dict, opti_state_dict = paddle.load("./test_dy")
para_state_dict, opti_state_dict = paddle.load("./test_dy_v2")
adam.set_state_dict(opti_state_dict)

opti_dict = adam.state_dict()
Expand Down Expand Up @@ -747,7 +747,7 @@ def testLoadAndSetVarBaseBeforeTrain(self):
last_hidden = None
last_cell = None

state_dict, opti_dict = fluid.load_dygraph("./test_dy")
state_dict, opti_dict = fluid.load_dygraph("./test_dy_v2")
adam.set_state_dict(opti_dict)
ptb_model.set_dict(state_dict)

Expand Down

1 comment on commit d5cf60e

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.