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

No Callbacks for Validation Batch Step - How To Get Progress of Validation? #1165

Closed
0x6b756d6172 opened this issue Mar 16, 2020 · 6 comments
Labels
feature Is an improvement or enhancement help wanted Open to be worked on

Comments

@0x6b756d6172
Copy link

0x6b756d6172 commented Mar 16, 2020

🚀 Feature

The Callbacks has two functions on_batch_start and on_batch_end. The documentation and code execution shows that these are only called for training batches, not validaton (or test). I am building a Callback for my own logging/dashboarding via Streamlit and I have a requirement to track the progress of both the train batch steps and validation batch steps during training. I see that there is a validation progress bar in the console during training - how is this implemented (if not via a Callback)?

Current Code

class MyCallback(pl.Callback):
    def on_train_start(self, trainer, pl_module):
        self.train_batch_count = 0
        self.train_batch_total = len(trainer.train_dataloader)

    def on_batch_end(self, train, pl_module):
        self.train_batch_count += 1
        percent_complete = self.train_batch_count / self.train_batch_total
        # display on screen

    def on_epoch_end(self, train, pl_module):
        self.train_batch_count = 0
@0x6b756d6172 0x6b756d6172 added feature Is an improvement or enhancement help wanted Open to be worked on labels Mar 16, 2020
@Borda
Copy link
Member

Borda commented Mar 16, 2020

hello, as you stated you want to have a logger, not a callback, you can write a custom logger...
Moreover, it would be welcome to add Streamlit.io as Lightning loggers, what do you think?

@0x6b756d6172
Copy link
Author

0x6b756d6172 commented Mar 16, 2020

Hi, @Borda, thanks for the reply. I looked over the documentation for Loggers and it will indeed be helpful for my future work. However, looking at LightiningLoggerBase, I don't see anything for capturing the epoch or batch progress for training (i.e. Epoch 1 of 5 or Batch 1 of 200) as I am doing above so that I can use Streamlit's streamlit.progress to render a progress bar of the batch, training and validation iterations.

I do think a Streamlit logger would be an excellent addition to Lightning but I am still in the early exploratory phase of using Streamlit myself and it currently seems like it would require a bit of work to make a useful generic dashboard a la Tensorboard. I'll continue experimenting on my end to see where it goes.

@awaelchli
Copy link
Contributor

In case this is still relevant to you, we now also have callbacks for validatation and test batches!
See https://pytorch-lightning.readthedocs.io/en/latest/callbacks.html#callback-base

@awaelchli
Copy link
Contributor

awaelchli commented May 3, 2020

Closing this. As far as i can tell, with the recently introduced new callback methods (validation_batch_start etc) it is now possible to track the progress as you desired.

@SouthMemory
Copy link

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

4 participants