Skip to content

Commit

Permalink
Add silent mode in recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger committed Dec 14, 2018
1 parent 2576143 commit 675a741
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastai/basic_train.py
Expand Up @@ -329,15 +329,15 @@ def __init__(self, learn:Learner):
super().__init__(learn)
self.opt = self.learn.opt
self.train_dl = self.learn.data.train_dl
self.no_val = False
self.no_val,self.silent = False,False

def on_train_begin(self, pbar:PBar, metrics_names:Collection[str], **kwargs:Any)->None:
"Initialize recording status at beginning of training."
self.pbar = pbar
self.names = ['epoch', 'train_loss'] if self.no_val else ['epoch', 'train_loss', 'valid_loss']
self.names += metrics_names
if hasattr(self, '_added_met_names'): self.names += self._added_met_names
self.pbar.write(self.names, table=True)
if not self.silent: self.pbar.write(self.names, table=True)
self.losses,self.val_losses,self.lrs,self.moms,self.metrics,self.nb_batches = [],[],[],[],[],[]

def on_batch_begin(self, train, **kwargs:Any)->None:
Expand Down Expand Up @@ -369,7 +369,7 @@ def format_stats(self, stats:TensorOrNumList)->None:
str_stats = []
for name,stat in zip(self.names,stats):
str_stats.append('' if stat is None else str(stat) if isinstance(stat, int) else f'{stat:.6f}')
self.pbar.write(str_stats, table=True)
if not self.silent: self.pbar.write(str_stats, table=True)

def add_metrics(self, metrics):
"Add `metrics` to the inner stats."
Expand Down

0 comments on commit 675a741

Please sign in to comment.