Skip to content

Init exporting and loading #376

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

Merged
merged 14 commits into from
Oct 13, 2021
Merged

Conversation

rnett
Copy link
Contributor

@rnett rnett commented Aug 28, 2021

This adds proper initializer exporting to SavedModelBundle, and fixes #365.

Won't be so big once #375 is merged.

@rnett
Copy link
Contributor Author

rnett commented Aug 28, 2021

Currently having issues since python does it's variable checkpoint restore, then runs init ops, which makes no sense.

I can manually run restore afterwards here, but that will run it twice, and doesn't help if you load the model in python.

@rnett
Copy link
Contributor Author

rnett commented Aug 28, 2021

I'm leaning towards not exporting our init ops at all (except maybe as bookkeeping). Any state initialized or changed within them will be handled by variable restoration anyways. And the only solution I can think of is removing Assign ops from the init ops before exporting or something similar, which is not great.

@karllessard
Copy link
Collaborator

@rnett , can you please rebase your PR since we have just upgraded to TF2.6.0 and all ops were updated as well?

@karllessard
Copy link
Collaborator

karllessard commented Sep 27, 2021

Currently having issues since python does it's variable checkpoint restore, then runs init ops, which makes no sense.

I can manually run restore afterwards here, but that will run it twice, and doesn't help if you load the model in python.

That is strange behavior if this is what is happening, indeed. Can you please provide more details on the purpose of this PR and summarize which what is the new logic flow in the init sequence when exporting/importing a model? I'm not sure to totally understand what are the impacts of these changes, thanks

rnett added 11 commits October 12, 2021 18:06
Signed-off-by: Ryan Nett <[email protected]>
Signed-off-by: Ryan Nett <[email protected]>
Signed-off-by: Ryan Nett <[email protected]>
Signed-off-by: Ryan Nett <[email protected]>
Signed-off-by: Ryan Nett <[email protected]>
@rnett rnett force-pushed the rn_init_exporting branch from 7afde14 to a23775f Compare October 13, 2021 01:06
@rnett
Copy link
Contributor Author

rnett commented Oct 13, 2021

Currently having issues since python does it's variable checkpoint restore, then runs init ops, which makes no sense.
I can manually run restore afterwards here, but that will run it twice, and doesn't help if you load the model in python.

That is strange behavior if this is what is happening, indeed. Can you please provide more details on the purpose of this PR and summarize which what is the new logic flow in the init sequence when exporting/importing a model? I'm not sure to totally understand what are the impacts of these changes, thanks

Yeah, I'm not sure why it's done that way. Nothing really changes on our end for initialization, things are just remembered better when using SavedModels. I.e. init ops will be correctly added to the init scope when loading a SavedModel, regardless of whether they were added from Python or Java (they won't be ran, since variables will already have been loaded). It also adds table init ops from some hub models as init ops, so that they are ran (see #365).

Signed-off-by: Ryan Nett <[email protected]>
@karllessard karllessard merged commit 2d449a6 into tensorflow:master Oct 13, 2021
@rnett rnett deleted the rn_init_exporting branch October 17, 2021 00:42
@karllessard karllessard mentioned this pull request Oct 20, 2021
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.

TFFailedPreconditionException with BigGAN-deep model from TensorFlow Hub
2 participants