in sing/fondation/trainer.py [0:0]
def _train_epoch(self, dataset, epoch):
"""
Train a single epoch on the given dataset and displays
statistics from time to time.
"""
loader = DataLoader(
dataset,
batch_size=self.batch_size,
shuffle=True,
collate_fn=collate)
iterator = utils.progress_iterator(loader, divisions=20)
total_loss = 0
with tqdm.tqdm(total=len(dataset), unit="ex") as bar:
for idx, (progress, batch) in enumerate(iterator):
if self.cuda:
batch.cuda_()
total_loss += self._train_batch(batch)
bar.update(len(batch))
if progress:
tqdm.tqdm.write(
"[train{}][{:03d}] {:.1f}%, loss {:.6f}".format(
self.suffix, epoch, progress,
total_loss / (idx + 1)))
return total_loss