Skip to content

Commit

Permalink
enable non-verbose mode in trainer and tester (dynamicslab#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Hamshaw, Scott Douglas <shamshaw@usgs.gov>
  • Loading branch information
shamshaw and Hamshaw, Scott Douglas committed Jun 4, 2023
1 parent e374e78 commit b3ab73c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion neuralhydrology/evaluation/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(self, cfg: Config, run_dir: Path, period: str = "test", init_model:
if self.init_model:
self.model = get_model(cfg).to(self.device)

self._disable_pbar = cfg.verbose == 0

# pre-initialize variables, defined in class methods
self.basins = None
self.scaler = None
Expand Down Expand Up @@ -190,7 +192,7 @@ def evaluate(self,

results = defaultdict(dict)

pbar = tqdm(basins, file=sys.stdout)
pbar = tqdm(basins, file=sys.stdout, disable=self._disable_pbar)
pbar.set_description('# Validation' if self.period == "validation" else "# Evaluation")

for basin in pbar:
Expand Down
3 changes: 2 additions & 1 deletion neuralhydrology/training/basetrainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, cfg: Config):
self._target_std = None
self._scaler = {}
self._allow_subsequent_nan_losses = cfg.allow_subsequent_nan_losses
self._disable_pbar = cfg.verbose == 0

# load train basin list and add number of basins to the config
self.basins = load_basin_file(cfg.train_basin_file)
Expand Down Expand Up @@ -273,7 +274,7 @@ def _train_epoch(self, epoch: int):
self.experiment_logger.train()

# process bar handle
pbar = tqdm(self.loader, file=sys.stdout)
pbar = tqdm(self.loader, file=sys.stdout, disable=self._disable_pbar)
pbar.set_description(f'# Epoch {epoch}')

# Iterate in batches over training set
Expand Down

0 comments on commit b3ab73c

Please sign in to comment.