|
|
|
@ -185,7 +185,6 @@ class Trainer():
|
|
|
|
|
|
|
|
|
|
def train(self):
|
|
|
|
|
"""The training process control by epoch."""
|
|
|
|
|
with Timer("Load/Init Model: {}"):
|
|
|
|
|
from_scratch = self.resume_or_scratch()
|
|
|
|
|
if from_scratch:
|
|
|
|
|
# save init model, i.e. 0 epoch
|
|
|
|
@ -196,6 +195,7 @@ class Trainer():
|
|
|
|
|
|
|
|
|
|
logger.info(f"Train Total Examples: {len(self.train_loader.dataset)}")
|
|
|
|
|
while self.epoch < self.config.training.n_epoch:
|
|
|
|
|
with Timer("Epoch-Train Time Cost: {}"):
|
|
|
|
|
self.model.train()
|
|
|
|
|
try:
|
|
|
|
|
data_start_time = time.time()
|
|
|
|
@ -214,6 +214,7 @@ class Trainer():
|
|
|
|
|
logger.error(e)
|
|
|
|
|
raise e
|
|
|
|
|
|
|
|
|
|
with Timer("Eval Time Cost: {}"):
|
|
|
|
|
total_loss, num_seen_utts = self.valid()
|
|
|
|
|
if dist.get_world_size() > 1:
|
|
|
|
|
num_seen_utts = paddle.to_tensor(num_seen_utts)
|
|
|
|
|