mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-10 12:21:57 +08:00
Fixed total number of batches (#439)
* Fixed total number of batches * Fixed flake8 warning * Update train_loop_mixin.py * Update train_loop_mixin.py
This commit is contained in:
committed by
William Falcon
parent
8347a6c87e
commit
9f8ab7c29e
@@ -23,7 +23,15 @@ class TrainerTrainLoopMixin(object):
|
||||
# update training progress in trainer and model
|
||||
model.current_epoch = epoch_nb
|
||||
self.current_epoch = epoch_nb
|
||||
self.total_batches = self.nb_training_batches + self.nb_val_batches
|
||||
|
||||
# val can be checked multiple times in epoch
|
||||
is_val_epoch = (self.current_epoch + 1) % self.check_val_every_n_epoch == 0
|
||||
val_checks_per_epoch = self.nb_training_batches // self.val_check_batch
|
||||
val_checks_per_epoch = val_checks_per_epoch if is_val_epoch else 0
|
||||
|
||||
# total batches includes multiple val checks
|
||||
self.total_batches = (self.nb_training_batches +
|
||||
self.nb_val_batches * val_checks_per_epoch)
|
||||
self.batch_loss_value = 0 # accumulated grads
|
||||
|
||||
# limit the number of batches to 1 in fast_dev_run
|
||||
|
||||
Reference in New Issue
Block a user