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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hparams are not automatically saved to WandB logger in 1.0.2 #4179

Closed
huyvnphan opened this issue Oct 15, 2020 · 5 comments 路 Fixed by #4189
Closed

Hparams are not automatically saved to WandB logger in 1.0.2 #4179

huyvnphan opened this issue Oct 15, 2020 · 5 comments 路 Fixed by #4189
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@huyvnphan
Copy link

馃悰 Bug

When I update to 1.0.2, when I assign self.hparams = args in Lightning module, the hparams are not logged in WandB anymore. This bug is not present in 1.0.0 however. Snippets of my code.

...
parser.add_argument("--description", type=str, default="Trainig")
...
args = parser.parse_args()
main(args)

# Inside main
logger = WandbLogger(name=args.description, project="myProject")
model = MyModule(args)

# Inside LightningModule
class MyModule(pl.LightningModule):
    def __init__(self, args):
        super().__init__()
        self.hparams = args
        ...
@huyvnphan huyvnphan added bug Something isn't working help wanted Open to be worked on labels Oct 15, 2020
@huyvnphan huyvnphan changed the title Hparams does not automactically saved to WandB logger in 1.0.2 Hparams is not automatically saved to WandB logger in 1.0.2 Oct 15, 2020
@huyvnphan huyvnphan changed the title Hparams is not automatically saved to WandB logger in 1.0.2 Hparams are not automatically saved to WandB logger in 1.0.2 Oct 15, 2020
@nateraw
Copy link
Contributor

nateraw commented Oct 15, 2020

If you aren't doing anything fancy w/ your args, its usually easier to explicitly type them. That's my quick answer, but it doesn't solve your problem. I've never used Wandb, but I'm giving it a go right now 馃槃 . will let ya know

@Borda
Copy link
Member

Borda commented Oct 15, 2020

well we are saving the initial arguments, so you should be calling self.save_hyperparameters()
this is not just the case of WandB, it is for all loggers since #4163

EDIT: the reccomended flow is:

class MyModule(pl.LightningModule):
    def __init__(self, arg1, arg2):
        super().__init__()
        self.save_hyperparameters()
        ...

@nateraw
Copy link
Contributor

nateraw commented Oct 15, 2020

Yeah your issue is solved if you just switch to using **kwargs. Also, make sure you're calling self.save_hyperparameters().

class YourModel(pl.LightningModule):
    def __init__(self, **kwargs):
        super().__init__()
        self.save_hyperparameters()

# ...

This made it work fine for me. seeing the correct hparams on WandB

@Borda
Copy link
Member

Borda commented Oct 15, 2020

Feel free to reopen if needed :]

@Borda Borda closed this as completed Oct 15, 2020
@nateraw
Copy link
Contributor

nateraw commented Oct 15, 2020

well we are saving the initial arguments, so you should be calling self.save_hyperparameters()
this is not just the case of WandB, it is for all loggers since #4163

EDIT: the reccomended flow is:

class MyModule(pl.LightningModule):
    def __init__(self, arg1, arg2):
        super().__init__()
        self.save_hyperparameters()
        ...

I also recommend writing the args explicitly. code just reads better that way (imo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants