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

Collect all the training_step outputs for training epoch end #2354

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pytorch_lightning/trainer/training_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def run_training_epoch(self):
# only track outputs when user implements training_epoch_end
# otherwise we will build up unnecessary memory
if self.is_overridden('training_epoch_end', model=self.get_model()):
epoch_output.append(batch_output.training_step_output_for_epoch_end)
epoch_output += batch_output.training_step_output_for_epoch_end
Borda marked this conversation as resolved.
Show resolved Hide resolved

# update LR schedulers
self.update_train_loop_lr_schedulers()
Expand Down Expand Up @@ -596,6 +596,9 @@ def run_training_batch(self, batch, batch_idx):
# track metrics to log
batch_log_metrics = []

# track all training_step output for epoch_end
training_step_output_for_epoch_end_list = []

if batch is None:
return AttributeDict(signal=0, grad_norm_dic=grad_norm_dic)

Expand Down Expand Up @@ -646,6 +649,7 @@ def run_training_batch(self, batch, batch_idx):
batch_callback_metrics.append(opt_closure_result.training_step_output.callback_metrics)
batch_log_metrics.append(opt_closure_result.training_step_output.log_metrics)
self.add_progress_bar_metrics(opt_closure_result.training_step_output.pbar_on_batch_end)
training_step_output_for_epoch_end_list.append(opt_closure_result.training_step_output_for_epoch_end)

# track hiddens
self.hiddens = opt_closure_result.hiddens
Expand Down Expand Up @@ -690,7 +694,7 @@ def run_training_batch(self, batch, batch_idx):
signal=0,
grad_norm_dic=grad_norm_dic,
batch_log_metrics=batch_log_metrics,
training_step_output_for_epoch_end=opt_closure_result.training_step_output_for_epoch_end
training_step_output_for_epoch_end=training_step_output_for_epoch_end_list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this here is now a list of outputs. This means we need to make sure the method which called this processes that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good 😄

)
return result

Expand Down