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

Fix Mixing hparams and arguments in LightningModule #1505

Merged
merged 9 commits into from
Apr 19, 2020

Conversation

HenryJia
Copy link
Contributor

@HenryJia HenryJia commented Apr 16, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Fixes #1468

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Apr 16, 2020

Codecov Report

Merging #1505 into master will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #1505   +/-   ##
======================================
- Coverage      91%     91%   -0%     
======================================
  Files          67      67           
  Lines        3784    3782    -2     
======================================
- Hits         3439    3437    -2     
  Misses        345     345           

@Borda Borda changed the title Fix #1468 Fix Mixing hparams and arguments in LightningModule Apr 16, 2020
@Borda Borda added the bug Something isn't working label Apr 16, 2020
@Borda Borda added this to the 0.7.4 milestone Apr 16, 2020
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
just thinking that kwargs shall be also filtered if the parameter has such attribute

@mergify mergify bot requested a review from a team April 16, 2020 12:01
@HenryJia
Copy link
Contributor Author

As in allow things in kwargs to override model_args?

@williamFalcon
Copy link
Contributor

williamFalcon commented Apr 16, 2020

i say keep it simple as this PR modifies

@williamFalcon
Copy link
Contributor

@HenryJia can you update the docs to show this?

@HenryJia
Copy link
Contributor Author

@williamFalcon Yep, done

Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

add note to changelog and think about adding test

@mergify mergify bot requested a review from a team April 16, 2020 19:46
@Borda Borda requested a review from williamFalcon April 16, 2020 19:46
@mergify
Copy link
Contributor

mergify bot commented Apr 17, 2020

This pull request is now in conflict... :(

@HenryJia
Copy link
Contributor Author

@Borda Added note to changelog, looking into clean ways of adding a test for this...

@awaelchli
Copy link
Contributor

awaelchli commented Apr 18, 2020

The note you added in the documentation could be confusing. I wouldn't call these extra arguments hyperparameters. Because to me it reads like you can do load_from_checkpoint(file, learning_rate=2) and then magically somewhere in Lightningmodule access it with hparams like self.hparams.learning_rate. But clearly this is not what you try to achieve. You simply want to pass in some extra args, in addition to hparams dict. Apart from that, I don't see why this implementation prevents anyone passing in arguments that ARE included in the hparams dict.

A reformulation and an example in the docs would make it clear (at least for me).

@HenryJia
Copy link
Contributor Author

HenryJia commented Apr 18, 2020

@awaelchli Sounds good I'll change it slightly then. Regarding the example, there already is one in the docs. It's the last example of that section.

@awaelchli
Copy link
Contributor

Awesome, it's cristal clear now. Thanks for the fix.

CHANGELOG.md Outdated Show resolved Hide resolved
@mergify mergify bot requested review from a team April 19, 2020 08:50
@williamFalcon williamFalcon merged commit 3c6f856 into Lightning-AI:master Apr 19, 2020
tullie pushed a commit to tullie/pytorch-lightning that referenced this pull request Jun 7, 2020
* Attempt to fix Lightning-AI#1468

* Remove the if statement, it doesn't actually make any difference

* Update docs

* Correct warnings I caused in the last commit

* Add to changelog

* Actually add to changelog

* Clarify documentation and examples

* Update CHANGELOG.md

Co-authored-by: Jirka Borovec <[email protected]>
@yukw777 yukw777 mentioned this pull request Jun 8, 2020
5 tasks
@Borda Borda modified the milestones: 0.7.4, v0.7.x Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mixing hparams and arguments in LightningModule.__init__() crashes load_from_checkpoint()
4 participants