Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init partial network parameters from another saved model. #2664

Merged
merged 6 commits into from
Jun 29, 2017

Conversation

qingqing01
Copy link
Contributor

@qingqing01 qingqing01 commented Jun 29, 2017

Fix #2663

The usage example is:

para = paddle.parameters.create(cost)
para.init_from_tar('init_params.tar.gz')

@@ -187,7 +184,7 @@ def __setitem__(self, key, value):
(shape, value.shape))

if len(self.__gradient_machines__) == 0:
self.__tmp_params__.append((key, value))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The append could lead the repeated key in self.__tmp_params__. This is a bug.

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

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

LGTM, except a tiny enhancement for Python syntax.

@@ -302,6 +299,12 @@ def from_tar(f):
params.deserialize(param_name, f)
return params

def init_from_tar(self, f):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because from_tar is a static method. Maybe Parameters.from_tar is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@pkuyym pkuyym left a comment

Choose a reason for hiding this comment

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

Maybe we should add comment to describe the usage scenario about from_tar and init_from_tar.

@qingqing01
Copy link
Contributor Author

@pkuyym add comments.

@NHZlX
Copy link
Contributor

NHZlX commented Jul 1, 2017

The usage example should be :

para = paddle.parameters.create(cost)
with gzip.open('init_params.tar.gz') as f:
     para.init_from_tar(f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants