Skip to content

W&B: Allow for passing experiment into the WandbLogger (and logging semantics) #711

@colehurwitz

Description

@colehurwitz

Currently, the WandbLogger will automatically create a new internal experiment (run) whenever you create a new WandbLogger.

Issue

If I instantiate a wandb experiment outside of the logger, then I will have two experiments when I train my model since there is no way to set the internal experiment of the WandbLogger to my current external experiment.

Potential Solution

Allow for passing an experiment into the WandbLogger:

class WandbLogger(LightningLoggerBase):
    def __init__(self, name=None, save_dir=None, offline=False, id=None, anonymous=False,
                 version=None, project=None, tags=None, experiment=None):
              .
              .
              .
              self._experiment = experiment

Then I can do this:

experiment = wandb.init(.......)
wandb_logger = WandbLogger(experiment=experiment)

I made this change locally, however, I wasn't sure if this was something you also wanted to implement as well. It works for me.

Another small note

In the WandbLogger.log_metrics function, I would change:

self.experiment.history.add(metrics) --> self.experiment.log(metrics)

Metadata

Metadata

Assignees

Labels

loggerRelated to the Loggers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions