Weights & Biases handler for MonAI#6519
Weights & Biases handler for MonAI#6519soumik12345 wants to merge 31 commits intoProject-MONAI:devfrom
Conversation
I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 062959c I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 42dc1fb I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 163364e I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: a01b2b0 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 38dd508 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 19380c5 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 3952742 Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com> [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
f9f6f49 to
3e0039a
Compare
I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 062959c I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 42dc1fb I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 163364e I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: a01b2b0 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 38dd508 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 19380c5 I, Soumik Rakshit <19soumik.rakshit96@gmail.com>, hereby add my Signed-off-by to this commit: 3952742 Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
for more information, see https://pre-commit.ci
| os.system("wandb offline") | ||
| os.environ["WANDB_DIR"] = tempdir.name | ||
|
|
||
| wandb.init(dir=tempdir.name) |
There was a problem hiding this comment.
I see the wandb is global, is it thread-safe and supports multi-processing?
I would suggest to add some tests to call wandb.init(dir=tempdir.name) and the whole handler in multi-thread and multi-processing logic.
For multi-processing test, you can refer to:
https://github.com/Project-MONAI/MONAI/blob/dev/tests/test_cumulative_average_dist.py
For multi-thread test, you can easily add a test function here, refer to:
https://github.com/Project-MONAI/MONAI/blob/dev/monai/data/dataset.py#L875-L878
What do you think?
Thanks.
| when every iteration completed. The default behavior is to print loss from output[0] as | ||
| output is a decollated list and we replicated loss value for every item of the decollated | ||
| list. `engine.state` and `output_transform` inherit from the | ||
| ignite concept: https://pytorch.org/ignite/concepts.html#state, explanation and usage |
There was a problem hiding this comment.
I cannot open the ignite concept link and the tutorial link below. May need to update these links.
Thanks,
Bin
| engine: Ignite Engine, it can be a trainer, validator or evaluator. | ||
| """ | ||
| if self.epoch_event_writer is not None: | ||
| self.epoch_event_writer(engine) |
There was a problem hiding this comment.
In the doc-string, it says that the epoch_event_writer: ..... Must accept the parameter "engine" and "summary_writer" ..... Whereas, I don't see the summary_writer parameter here. It's a little bit confusing for me. Could you please explain it?
Thanks,
Bin
There was a problem hiding this comment.
Its a typo from an older draft of the PR, where I was mimicking the behavior of the Tensorboard Stats handler. I will update the docstring.
|
|
||
| def __init__( | ||
| self, | ||
| iteration_log: bool = True, |
There was a problem hiding this comment.
Shoud a dict parameter like hyperparameters be added to the init function to record some users defined parameters with wandb.config?
Thanks,
Bin
|
@SachidanandAlle Can help share more concerns about multi-thread running of the hander. Thanks. |
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
|
Hi @soumik12345 , Do you still plan to complete this PR? Thanks. |
Hi @Nic-Ma |
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
Signed-off-by: Soumik Rakshit <19soumik.rakshit96@gmail.com>
for more information, see https://pre-commit.ci
|
Is this still being worked on? |
|
Hi @DanielNobbe sorry about this PR, it has seemingly fallen through the cracks quite a while ago. @soumik12345 I realised this is rather old now but would you be able to update the PR so we can merge this? Looking at it now I think we're fine to merge this if we can resolve the conflicts and run the tests. Thanks! |

Features Contributed
WandbStatsHandlerdefines a set of Ignite Event-handlers for all the Weights & Biases logging logic. It can be used for any Ignite Engine(trainer, validator, and evaluator) and support both epoch level and iteration level. The expected data source is Igniteengine.state.outputandengine.state.metrics. Default behaviors:EPOCH_COMPLETED, write each dictionary item inengine.state.metricsto Weights & Biases.ITERATION_COMPLETED, write each dictionary item inself.output_transform(engine.state.output)to Weights & Biases.The following colab notebook and Weights & Biases run demonstrate the usage of these handlers and their results respectively:
Some additional Weights & Biases features:
TensorBoardStatsHandlerandTensorBoardImageHandlerare used inside a wandb run, Weights & Biases automatically hosts the Tensorboard instance inside the run if duringwandb.init(),sync_tensorboardis set toTrue.TensorBoardImageHandler, the images and videos are automatically logged to Weights & Biases media panel if duringwandb.init(),sync_tensorboardis set toTrue.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.