Skip to content

Empty "outputs" argument in the on_train_batch_end() method of Callback #5517

@cemanil

Description

@cemanil

🐛 Bug

The "outputs" argument of the 'on_train_batch_end' method of a lightning Callback seems to be empty, unless training_epoch_end() is implemented in the lightning model.

I'm looking for a way to process the outputs of training_step() in a callback. If I'm not mistaken, the "outputs" argument of the on_train_batch_end() of a lightning callback is meant for use cases like this. If I don't implement the training_epoch_end() method in my lightning model, the "outputs" argument is consistently an empty list. Implementing training_epoch_end() does fill the "outputs" argument with the output of training_step(), but I'd like to avoid this, as keeping track of all the training_step outputs for an entire epoch might be memory intensive.

Reproducing the issue

To Reproduce

The following link BoringModel contains the behaviour I'm referring to.

Expected behavior

The "outputs" argument of the on_train_batch_end() method of a lightning callback is an empty list if one comments out train_epoch_end() in the lightning model.

Environment

  • CUDA:
    • GPU:
      • Tesla T4
    • available: True
    • version: 10.1
  • Packages:
    • numpy: 1.19.5
    • pyTorch_debug: True
    • pyTorch_version: 1.7.0+cu101
    • pytorch-lightning: 1.1.4
    • tqdm: 4.41.1
  • System:
    • OS: Linux
    • architecture:
      • 64bit
    • processor: x86_64
    • python: 3.6.9
    • version: Proposal for help #1 SMP Thu Jul 23 08:00:38 PDT 2020

Additional context

If this is a feature rather than a bug, how do you recommend we use the outputs of training_step in a callback without having to track all training_step outputs for an entire epoch?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedOpen to be worked onpriority: 1Medium priority task

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions