Skip to content

Commit b492e2b

Browse files
elliotwaitewilliamFalcon
authored andcommitted
Change nb to num in ABCs, comments, and tqdm logging (Lightning-AI#613)
* Change nb to num in ABCs, comments, and tqdm logging * Fix warnings text * Make warnings one line * Change num to number in comments
1 parent 607dbda commit b492e2b

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

pytorch_lightning/trainer/evaluation_loop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def __init__(self):
145145
self.single_gpu = None
146146
self.data_parallel_device_ids = None
147147
self.model = None
148-
self.nb_test_batches = None
149-
self.nb_val_batches = None
148+
self.num_test_batches = None
149+
self.num_val_batches = None
150150
self.fast_dev_run = None
151151
self.process_position = None
152152
self.show_progress_bar = None

pytorch_lightning/trainer/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def reduce_distributed_output(self, output, num_gpus):
177177
elif isinstance(output[k], torch.Tensor) and output[k].dim() == 0:
178178
pass
179179

180-
# reduce only metrics that have the same nb of gpus
180+
# reduce only metrics that have the same number of gpus
181181
elif output[k].size(0) == num_gpus:
182182
reduced = torch.mean(output[k])
183183
output[k] = reduced

pytorch_lightning/trainer/trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def training_tqdm_dict(self):
346346
tqdm_dict['split_idx'] = self.split_idx
347347

348348
if self.logger is not None and self.logger.version is not None:
349-
tqdm_dict['v_nb'] = self.logger.version
349+
tqdm_dict['v_num'] = self.logger.version
350350

351351
tqdm_dict.update(self.tqdm_metrics)
352352

pytorch_lightning/trainer/training_loop.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def training_step(self, batch, batch_idx):
151151

152152
import inspect
153153
from abc import ABC, abstractmethod
154+
import warnings
154155

155156
import numpy as np
156157

@@ -169,22 +170,22 @@ class TrainerTrainLoopMixin(ABC):
169170
def __init__(self):
170171
# this is just a summary on variables used in this abstract class,
171172
# the proper values/initialisation should be done in child class
172-
self.max_nb_epochs = None
173+
self.max_epochs = None
174+
self.min_epochs = None
173175
self.use_ddp = None
174176
self.use_dp = None
175177
self.use_ddp2 = None
176178
self.single_gpu = None
177179
self.data_parallel_device_ids = None
178180
self.check_val_every_n_epoch = None
179-
self.nb_training_batches = None
181+
self.num_training_batches = None
180182
self.val_check_batch = None
181-
self.nb_val_batches = None
183+
self.num_val_batches = None
182184
self.fast_dev_run = None
183185
self.is_iterable_train_dataloader = None
184186
self.main_progress_bar = None
185187
self.accumulation_scheduler = None
186188
self.lr_schedulers = None
187-
self.min_nb_epochs = None
188189
self.enable_early_stop = None
189190
self.early_stop_callback = None
190191
self.callback_metrics = None
@@ -194,7 +195,7 @@ def __init__(self):
194195
self.log_save_interval = None
195196
self.proc_rank = None
196197
self.row_log_interval = None
197-
self.total_batch_nb = None
198+
self.total_batches = None
198199
self.truncated_bptt_steps = None
199200
self.optimizers = None
200201
self.accumulate_grad_batches = None
@@ -207,6 +208,24 @@ def __init__(self):
207208
self.get_train_dataloader = None
208209
self.reduce_lr_on_plateau_scheduler = None
209210

211+
@property
212+
def max_nb_epochs(self):
213+
"""
214+
.. warning:: `max_nb_epochs` is deprecated and will be removed in v0.8.0, use `max_epochs` instead.
215+
"""
216+
warnings.warn("`max_nb_epochs` is deprecated and will be removed in "
217+
"v0.8.0, use `max_epochs` instead.", DeprecationWarning)
218+
return self.max_epochs
219+
220+
@property
221+
def min_nb_epochs(self):
222+
"""
223+
.. warning:: `min_nb_epochs` is deprecated and will be removed in v0.8.0, use `min_epochs` instead.
224+
"""
225+
warnings.warn("`min_nb_epochs` is deprecated and will be removed in "
226+
"v0.8.0, use `min_epochs` instead.", DeprecationWarning)
227+
return self.min_epochs
228+
210229
@abstractmethod
211230
def get_model(self):
212231
# this is just empty shell for code from other class
@@ -391,7 +410,7 @@ def run_training_epoch(self):
391410
if early_stop_epoch or self.fast_dev_run:
392411
break
393412

394-
# stop epoch if we limited nb batches
413+
# stop epoch if we limited the number of training batches
395414
met_batch_limit = batch_idx >= self.num_training_batches
396415
if met_batch_limit:
397416
break

0 commit comments

Comments
 (0)