Skip to content

Commit

Permalink
Fix train_loader not initalized properly (#981)
Browse files Browse the repository at this point in the history
* fix

* fix typo

* typo
  • Loading branch information
Louis-Dupont authored and avideci committed May 23, 2023
1 parent d9a7b63 commit 7ec9535
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/super_gradients/training/sg_trainer/sg_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def __init__(self, experiment_name: str, device: str = None, multi_gpu: Union[Mu

# SET THE EMPTY PROPERTIES
self.net, self.architecture, self.arch_params, self.dataset_interface = None, None, None, None
self.train_loader, self.valid_loader = None, None
self.ema = None
self.ema_model = None
self.sg_logger = None
Expand Down Expand Up @@ -996,8 +997,15 @@ def forward(self, inputs, targets):
global logger
if training_params is None:
training_params = dict()
self.train_loader = train_loader or self.train_loader
self.valid_loader = valid_loader or self.valid_loader

self.train_loader = train_loader if train_loader is not None else self.train_loader
self.valid_loader = valid_loader if valid_loader is not None else self.valid_loader

if self.train_loader is None:
raise ValueError("No `train_loader` found. Please provide a value for `train_loader`")

if self.valid_loader is None:
raise ValueError("No `valid_loader` found. Please provide a value for `valid_loader`")

if hasattr(self.train_loader, "batch_sampler") and self.train_loader.batch_sampler is not None:
batch_size = self.train_loader.batch_sampler.batch_size
Expand Down

0 comments on commit 7ec9535

Please sign in to comment.