|
|
|
@ -34,6 +34,7 @@ from deepspeech.io.sampler import SortagradDistributedBatchSampler
|
|
|
|
|
from deepspeech.models.u2 import U2Model
|
|
|
|
|
from deepspeech.training.optimizer import OptimizerFactory
|
|
|
|
|
from deepspeech.training.scheduler import LRSchedulerFactory
|
|
|
|
|
from deepspeech.training.timer import Timer
|
|
|
|
|
from deepspeech.training.trainer import Trainer
|
|
|
|
|
from deepspeech.utils import ctc_utils
|
|
|
|
|
from deepspeech.utils import error_rate
|
|
|
|
@ -184,11 +185,12 @@ class U2Trainer(Trainer):
|
|
|
|
|
self.save(tag='init')
|
|
|
|
|
|
|
|
|
|
self.lr_scheduler.step(self.iteration)
|
|
|
|
|
if self.parallel:
|
|
|
|
|
if self.parallel and hasattr(self.train_loader, 'batch_sampler'):
|
|
|
|
|
self.train_loader.batch_sampler.set_epoch(self.epoch)
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
@ -207,6 +209,7 @@ class U2Trainer(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)
|
|
|
|
|