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

add test for reloading lookahead optimizer #2102

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

add test for reloading lookahead optimizer #2102

wants to merge 5 commits into from

Conversation

BinyanHu
Copy link

Description

Brief Description of the PR: add the test for saving and reloading a Lookahead optimizer. The added test function reveals the bug that the states of a lookahead's inner optimizer are not properly saved and reloaded (#2094). So the test can not pass currently.

Type of change

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running Black + Flake8
    • By running pre-commit hooks
  • This PR addresses an already submitted issue for TensorFlow Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • This PR contains modifications to C++ custom-ops

How Has This Been Tested?

If you're adding a bugfix or new feature please describe the tests that you ran to verify your changes:

@bot-of-gabrieldemarmiesse

@CyberZHG

You are owner of some files modified in this pull request.
Would you kindly review the changes whenever you have the time to?
Thank you very much.

@bhack
Copy link
Contributor

bhack commented Aug 19, 2020

The original tests mentioned in the ticket was testing model serializzation?
What are you testing with save and load weights?

@BinyanHu
Copy link
Author

The original tests mentioned in the ticket was testing model serializzation?
What are you testing with save and load weights?

The description from the ticket was inaccurate. I raised that issue and the problem is on save and reloading. Please check the the discussions in the issue(#2094) for more details.

@bhack
Copy link
Contributor

bhack commented Aug 19, 2020

I was talking about save and reloading original contributor test in https://github.com/CyberZHG/keras-lookahead/blob/master/tests/test_optimizers.py

@BinyanHu
Copy link
Author

I was talking about save and reloading original contributor test in https://github.com/CyberZHG/keras-lookahead/blob/master/tests/test_optimizers.py

That is a different way to save a model. The contributor test uses model.save and keras.models.load_model to save and load the entire graph. In our case, we are using model.save_weights and model.load_weights to save and load only the weights of a model.

@BinyanHu
Copy link
Author

I was talking about save and reloading original contributor test in https://github.com/CyberZHG/keras-lookahead/blob/master/tests/test_optimizers.py

Just updated the test file referring to the original contributor test. I added cases of whether the inner optimizer contains slots (adam) or not (sgd) and different saving and reloading methods (weights only and whole graph). All tests of "sgd" pass and those of "adam" fail, which I believe should be enough to demonstrate the problem.

@bhack
Copy link
Contributor

bhack commented Aug 20, 2020

bhack added a commit that referenced this pull request Aug 27, 2020
bhack added a commit that referenced this pull request Aug 27, 2020
@bhack bhack mentioned this pull request Aug 27, 2020
17 tasks
@bhack bhack requested a review from WindQAQ August 30, 2020 10:57
@bhack
Copy link
Contributor

bhack commented Aug 30, 2020

@WindQAQ Let me know if you still find useful to have a save_weight/load_weight test. In that case give a pass over the test.

WindQAQ pushed a commit that referenced this pull request Sep 1, 2020
* Update lookahead.py

Inital fix of 
#2094
#2102

* Fix linting

* Resolve name conflict with mixed prexision

* Track baseline optimizer in avg
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* Update lookahead.py

Inital fix of 
tensorflow#2094
tensorflow#2102

* Fix linting

* Resolve name conflict with mixed prexision

* Track baseline optimizer in avg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants