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

Wandb logger #926

Merged
merged 14 commits into from
Apr 22, 2020
Merged

Wandb logger #926

merged 14 commits into from
Apr 22, 2020

Conversation

fdlm
Copy link
Contributor

@fdlm fdlm commented Apr 16, 2020

Fixes #865

Description:

Implements logging to Weights & Biases.

Potential problems:

  • No integration testing, because you need a W&B login to initialize the logger.

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 16, 2020

FYI, just found on their site : https://github.com/wandb/gitbook/blob/master/library/frameworks/pytorch/ignite.md

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 16, 2020

@fdlm thanks for the PR ! Could you please provide MNIST example of using WandB like https://github.com/pytorch/ignite/blob/master/examples/contrib/mnist/mnist_with_neptune_logger.py

@vfdev-5 vfdev-5 requested a review from sdesrozis April 18, 2020 20:48
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 18, 2020

@sdesrozis could you please check mnist example by running it locally. Thanks!

criterion = nn.CrossEntropyLoss()
trainer = create_supervised_trainer(model, optimizer, criterion, device=device)

if sys.version_info > (3,):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can remove GPU logging as W&D does it by itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will fix.

},
)

def iteration(engine):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use global_step_from_engine instead of iteration:
global_step_transform=global_step_from_engine(trainer)

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 problem is that global_step_from_engine will use the iteration number for handlers called on Events.ITERATION_COMPLETED, but epoch number for handlers called on Events.EPOCH_COMPLETED. W&B does not allow to log events with a smaller step than previously logged, so I need to make sure to always use the iteration number.

Copy link
Collaborator

@vfdev-5 vfdev-5 Apr 19, 2020

Choose a reason for hiding this comment

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

OK, I see what you mean. So, we can not log at all any epoch number if we log iterations ?

Anyway, we can do that iteration(engine) in a more simple way:

global_step_transform=lambda _, _: trainer.state.iteration 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, at least not directly. The workaround (as described in the W&B docs) is to log epochs as "metric", and then select it as X-axis in the W&B web interface. Not sure how to facilitate this in the Logger here.

Thanks for the simpler global_step_transform, will add it!

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 18, 2020

@fdlm thanks for the update!
I left some comments to improve example's code ?
And it remains to update the docs as here: https://github.com/pytorch/ignite/blob/master/docs/source/contrib/handlers.rst#neptune_logger

@sdesrozis
Copy link
Contributor

sdesrozis commented Apr 18, 2020

WB is just an awesome logger !! That works perfectly. Data in cloud on W&B are amazing. Very very nice job :)

Copy link
Contributor

@sdesrozis sdesrozis left a comment

Choose a reason for hiding this comment

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

Very good. We can merge the PR when conversations will be resolved.

@sdesrozis sdesrozis merged commit 0b36397 into pytorch:master Apr 22, 2020
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.

Add W&B logger
3 participants