提交 054e099b 编写于 作者: H Hui Zhang

format

上级 0e91d26a
...@@ -35,8 +35,8 @@ from deepspeech.models.ds2 import DeepSpeech2Model ...@@ -35,8 +35,8 @@ from deepspeech.models.ds2 import DeepSpeech2Model
from deepspeech.models.ds2_online import DeepSpeech2InferModelOnline from deepspeech.models.ds2_online import DeepSpeech2InferModelOnline
from deepspeech.models.ds2_online import DeepSpeech2ModelOnline from deepspeech.models.ds2_online import DeepSpeech2ModelOnline
from deepspeech.training.gradclip import ClipGradByGlobalNormWithLog from deepspeech.training.gradclip import ClipGradByGlobalNormWithLog
from deepspeech.training.trainer import Trainer
from deepspeech.training.reporter import report from deepspeech.training.reporter import report
from deepspeech.training.trainer import Trainer
from deepspeech.utils import error_rate from deepspeech.utils import error_rate
from deepspeech.utils import layer_tools from deepspeech.utils import layer_tools
from deepspeech.utils import mp_tools from deepspeech.utils import mp_tools
...@@ -108,7 +108,7 @@ class DeepSpeech2Trainer(Trainer): ...@@ -108,7 +108,7 @@ class DeepSpeech2Trainer(Trainer):
report("batch_size", batch_size) report("batch_size", batch_size)
report("accum", accum_grad) report("accum", accum_grad)
report("step_cost", iteration_time) report("step_cost", iteration_time)
if dist.get_rank() == 0 and self.visualizer: if dist.get_rank() == 0 and self.visualizer:
for k, v in losses_np.items(): for k, v in losses_np.items():
# `step -1` since we update `step` after optimizer.step(). # `step -1` since we update `step` after optimizer.step().
......
...@@ -34,11 +34,11 @@ from deepspeech.io.sampler import SortagradBatchSampler ...@@ -34,11 +34,11 @@ from deepspeech.io.sampler import SortagradBatchSampler
from deepspeech.io.sampler import SortagradDistributedBatchSampler from deepspeech.io.sampler import SortagradDistributedBatchSampler
from deepspeech.models.u2 import U2Model from deepspeech.models.u2 import U2Model
from deepspeech.training.optimizer import OptimizerFactory from deepspeech.training.optimizer import OptimizerFactory
from deepspeech.training.reporter import ObsScope
from deepspeech.training.reporter import report
from deepspeech.training.scheduler import LRSchedulerFactory from deepspeech.training.scheduler import LRSchedulerFactory
from deepspeech.training.timer import Timer from deepspeech.training.timer import Timer
from deepspeech.training.trainer import Trainer from deepspeech.training.trainer import Trainer
from deepspeech.training.reporter import report
from deepspeech.training.reporter import ObsScope
from deepspeech.utils import ctc_utils from deepspeech.utils import ctc_utils
from deepspeech.utils import error_rate from deepspeech.utils import error_rate
from deepspeech.utils import layer_tools from deepspeech.utils import layer_tools
...@@ -207,17 +207,21 @@ class U2Trainer(Trainer): ...@@ -207,17 +207,21 @@ class U2Trainer(Trainer):
report("Rank", dist.get_rank()) report("Rank", dist.get_rank())
report("epoch", self.epoch) report("epoch", self.epoch)
report('step', self.iteration) report('step', self.iteration)
report('step/total', (batch_index + 1) / len(self.train_loader)) report('step/total',
(batch_index + 1) / len(self.train_loader))
report("lr", self.lr_scheduler()) report("lr", self.lr_scheduler())
self.train_batch(batch_index, batch, msg) self.train_batch(batch_index, batch, msg)
self.after_train_batch() self.after_train_batch()
report('reader_cost', dataload_time) report('reader_cost', dataload_time)
observation['batch_cost'] = observation['reader_cost']+observation['step_cost'] observation['batch_cost'] = observation[
'reader_cost'] + observation['step_cost']
observation['samples'] = observation['batch_size'] observation['samples'] = observation['batch_size']
observation['ips[sent./sec]'] = observation['batch_size'] / observation['batch_cost'] observation['ips[sent./sec]'] = observation[
'batch_size'] / observation['batch_cost']
for k, v in observation.items(): for k, v in observation.items():
msg += f" {k}: " msg += f" {k}: "
msg += f"{v:>.8f}" if isinstance(v, float) else f"{v}" msg += f"{v:>.8f}" if isinstance(v,
float) else f"{v}"
msg += "," msg += ","
logger.info(msg) logger.info(msg)
data_start_time = time.time() data_start_time = time.time()
......
...@@ -20,8 +20,8 @@ from paddle.nn import Layer ...@@ -20,8 +20,8 @@ from paddle.nn import Layer
from . import extension from . import extension
from ..reporter import DictSummary from ..reporter import DictSummary
from ..reporter import report
from ..reporter import ObsScope from ..reporter import ObsScope
from ..reporter import report
from ..timer import Timer from ..timer import Timer
from deepspeech.utils.log import Log from deepspeech.utils.log import Log
logger = Log(__name__).getlog() logger = Log(__name__).getlog()
......
...@@ -13,16 +13,16 @@ ...@@ -13,16 +13,16 @@
# limitations under the License. # limitations under the License.
import sys import sys
import time import time
from pathlib import Path
from collections import OrderedDict from collections import OrderedDict
from pathlib import Path
import paddle import paddle
from paddle import distributed as dist from paddle import distributed as dist
from tensorboardX import SummaryWriter from tensorboardX import SummaryWriter
from deepspeech.training.timer import Timer
from deepspeech.training.reporter import report
from deepspeech.training.reporter import ObsScope from deepspeech.training.reporter import ObsScope
from deepspeech.training.reporter import report
from deepspeech.training.timer import Timer
from deepspeech.utils import mp_tools from deepspeech.utils import mp_tools
from deepspeech.utils import profiler from deepspeech.utils import profiler
from deepspeech.utils.checkpoint import Checkpoint from deepspeech.utils.checkpoint import Checkpoint
...@@ -30,7 +30,6 @@ from deepspeech.utils.log import Log ...@@ -30,7 +30,6 @@ from deepspeech.utils.log import Log
from deepspeech.utils.utility import seed_all from deepspeech.utils.utility import seed_all
from deepspeech.utils.utility import UpdateConfig from deepspeech.utils.utility import UpdateConfig
__all__ = ["Trainer"] __all__ = ["Trainer"]
logger = Log(__name__).getlog() logger = Log(__name__).getlog()
...@@ -236,17 +235,21 @@ class Trainer(): ...@@ -236,17 +235,21 @@ class Trainer():
report("Rank", dist.get_rank()) report("Rank", dist.get_rank())
report("epoch", self.epoch) report("epoch", self.epoch)
report('step', self.iteration) report('step', self.iteration)
report('step/total', (batch_index + 1) / len(self.train_loader)) report('step/total',
(batch_index + 1) / len(self.train_loader))
report("lr", self.lr_scheduler()) report("lr", self.lr_scheduler())
self.train_batch(batch_index, batch, msg) self.train_batch(batch_index, batch, msg)
self.after_train_batch() self.after_train_batch()
report('reader_cost', dataload_time) report('reader_cost', dataload_time)
observation['batch_cost'] = observation['reader_cost']+observation['step_cost'] observation['batch_cost'] = observation[
'reader_cost'] + observation['step_cost']
observation['samples'] = observation['batch_size'] observation['samples'] = observation['batch_size']
observation['ips[sent./sec]'] = observation['batch_size'] / observation['batch_cost'] observation['ips[sent./sec]'] = observation[
'batch_size'] / observation['batch_cost']
for k, v in observation.items(): for k, v in observation.items():
msg += f" {k}: " msg += f" {k}: "
msg += f"{v:>.8f}" if isinstance(v, float) else f"{v}" msg += f"{v:>.8f}" if isinstance(v,
float) else f"{v}"
msg += "," msg += ","
logger.info(msg) logger.info(msg)
data_start_time = time.time() data_start_time = time.time()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册