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

Support multiple loggers at once #825

Closed
williamFalcon opened this issue Feb 12, 2020 · 12 comments
Closed

Support multiple loggers at once #825

williamFalcon opened this issue Feb 12, 2020 · 12 comments
Assignees
Labels
feature Is an improvement or enhancement help wanted Open to be worked on
Milestone

Comments

@williamFalcon
Copy link
Contributor

🚀 Feature

Users might want to use more than 1 loggers at once

@williamFalcon williamFalcon added feature Is an improvement or enhancement help wanted Open to be worked on labels Feb 12, 2020
@williamFalcon williamFalcon added this to the 0.6.1 milestone Feb 12, 2020
@ethanwharris
Copy link
Member

A good way to do this might be to create a ListLogger class or similar that takes a list of loggers and iterates over them on each call. Can then make this happen auto-magically in the Trainer when a list of loggers is given. Any issues with this approach @PyTorchLightning/core-contributors ? Otherwise I'm happy to implement it :)

@Borda
Copy link
Member

Borda commented Feb 19, 2020

The LoggerCollection sounds good, a user would pass list loggers he wants to use and then under the hood, it will be transformed to this wrapper...
Moreover, we may do the same, simplified API, with callbacks... as e.g. Keras did, pass just list of callbacks to be executed and Trainer will call then when needed instead of having them specified
https://github.com/PyTorchLightning/pytorch-lightning/blob/b1040523b2180300574d961444b00abfa3c84195/pytorch_lightning/trainer/trainer.py#L65-L66

@ethanwharris
Copy link
Member

Yeah, that sounds good, I'll do this for Loggers first and then we can think about following up for callbacks

@williamFalcon
Copy link
Contributor Author

williamFalcon commented Feb 19, 2020

why not just take in the list of loggers

# default logger
Trainer(logger=True)

# no logger
Trainer(logger=False)

# single logger
Trainer(logger=Logger)

# n loggers
Trainer(logger=[a, b, c])

And anytime we call the logger right now internally, we replace with a call to all of them.

@ethanwharris
Copy link
Member

The value of a LoggerList object or similar here is that the Trainer code doesn't need to care how the Loggers were given except in the init where it wraps them. The API the user sees will be the same, but it seems more encapsulated this way. That said, either option is fine in that they will both give the same result. Any strong opinions for either option? Otherwise I tend towards a LoggerList

@Borda
Copy link
Member

Borda commented Feb 19, 2020

as I mentioned, we would keep the API as Will gave example but under the hood, we would use a class iteration loggers co you do not repeat looping over all logger or checking if there is just one or more...

@williamFalcon
Copy link
Contributor Author

williamFalcon commented Feb 19, 2020

Yeah, i think under the hood a loggerlist or some class to encapsulate makes sense as @ethanwharris mentioned! To the user though they should just intuit that they can pass in a list of loggers.

@srush thoughts?

@srush
Copy link
Contributor

srush commented Feb 19, 2020

Yup, the user API of torch-lightning seems to be that passing/returning lists just works, so I like that style.

@Borda Borda mentioned this issue Feb 19, 2020
@Borda Borda modified the milestones: 0.6.1, 0.6.2 Feb 25, 2020
@williamFalcon williamFalcon modified the milestones: 0.6.2, 0.6.1 Feb 25, 2020
@ethanwharris
Copy link
Member

Closed by #903

@RAraghavarora
Copy link

Can we multiple loggers to use for different metrics?
For example, when I log the train_loss, I want it to be in a separate file than val_loss:

weight_change_logger = CSVLogger('logs', name='weight_changes')
train_loss_logger = CSVLogger('logs', name='train_loss')
val_loss_logger = CSVLogger('logs', name='val_loss')

@vidhi0206
Copy link

Can we multiple loggers to use for different metrics? For example, when I log the train_loss, I want it to be in a separate file than val_loss:

weight_change_logger = CSVLogger('logs', name='weight_changes')
train_loss_logger = CSVLogger('logs', name='train_loss')
val_loss_logger = CSVLogger('logs', name='val_loss')

Did you get the answer of how to do it? I am not able to find the answer

@RAraghavarora
Copy link

Can we multiple loggers to use for different metrics? For example, when I log the train_loss, I want it to be in a separate file than val_loss:

weight_change_logger = CSVLogger('logs', name='weight_changes')
train_loss_logger = CSVLogger('logs', name='train_loss')
val_loss_logger = CSVLogger('logs', name='val_loss')

Did you get the answer of how to do it? I am not able to find the answer

No... I didn't, and ended up giving up on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

6 participants