Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
676ebcdf
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
1 年多 前同步成功
通知
207
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
676ebcdf
编写于
4月 15, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix logger
上级
e61a6134
变更
34
显示空白变更内容
内联
并排
Showing
34 changed file
with
125 addition
and
93 deletion
+125
-93
deepspeech/__init__.py
deepspeech/__init__.py
+3
-23
deepspeech/exps/deepspeech2/model.py
deepspeech/exps/deepspeech2/model.py
+2
-2
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+2
-2
deepspeech/frontend/augmentor/spec_augment.py
deepspeech/frontend/augmentor/spec_augment.py
+2
-2
deepspeech/frontend/utility.py
deepspeech/frontend/utility.py
+2
-2
deepspeech/io/collator.py
deepspeech/io/collator.py
+3
-3
deepspeech/io/dataset.py
deepspeech/io/dataset.py
+3
-3
deepspeech/io/sampler.py
deepspeech/io/sampler.py
+3
-3
deepspeech/io/utility.py
deepspeech/io/utility.py
+3
-3
deepspeech/models/deepspeech2.py
deepspeech/models/deepspeech2.py
+2
-2
deepspeech/models/u2.py
deepspeech/models/u2.py
+2
-2
deepspeech/modules/activation.py
deepspeech/modules/activation.py
+2
-2
deepspeech/modules/attention.py
deepspeech/modules/attention.py
+2
-2
deepspeech/modules/cmvn.py
deepspeech/modules/cmvn.py
+2
-2
deepspeech/modules/conformer_convolution.py
deepspeech/modules/conformer_convolution.py
+2
-2
deepspeech/modules/conv.py
deepspeech/modules/conv.py
+2
-2
deepspeech/modules/ctc.py
deepspeech/modules/ctc.py
+2
-2
deepspeech/modules/decoder.py
deepspeech/modules/decoder.py
+2
-2
deepspeech/modules/decoder_layer.py
deepspeech/modules/decoder_layer.py
+2
-2
deepspeech/modules/embedding.py
deepspeech/modules/embedding.py
+2
-2
deepspeech/modules/encoder.py
deepspeech/modules/encoder.py
+2
-2
deepspeech/modules/encoder_layer.py
deepspeech/modules/encoder_layer.py
+2
-2
deepspeech/modules/loss.py
deepspeech/modules/loss.py
+2
-2
deepspeech/modules/mask.py
deepspeech/modules/mask.py
+2
-2
deepspeech/modules/positionwise_feed_forward.py
deepspeech/modules/positionwise_feed_forward.py
+2
-2
deepspeech/modules/rnn.py
deepspeech/modules/rnn.py
+2
-2
deepspeech/modules/subsampling.py
deepspeech/modules/subsampling.py
+2
-2
deepspeech/training/gradclip.py
deepspeech/training/gradclip.py
+3
-3
deepspeech/training/scheduler.py
deepspeech/training/scheduler.py
+2
-2
deepspeech/training/trainer.py
deepspeech/training/trainer.py
+2
-2
deepspeech/utils/checkpoint.py
deepspeech/utils/checkpoint.py
+2
-2
deepspeech/utils/ctc_utils.py
deepspeech/utils/ctc_utils.py
+2
-2
deepspeech/utils/log.py
deepspeech/utils/log.py
+52
-0
deepspeech/utils/tensor_utils.py
deepspeech/utils/tensor_utils.py
+3
-3
未找到文件。
deepspeech/__init__.py
浏览文件 @
676ebcdf
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
logging
from
typing
import
Union
from
typing
import
Union
from
typing
import
List
from
typing
import
List
from
typing
import
Tuple
from
typing
import
Tuple
...
@@ -23,30 +22,11 @@ from paddle.nn import functional as F
...
@@ -23,30 +22,11 @@ from paddle.nn import functional as F
#TODO(Hui Zhang): remove fluid import
#TODO(Hui Zhang): remove fluid import
from
paddle.fluid
import
core
from
paddle.fluid
import
core
root
=
logging
.
getLogger
()
from
deepspeech.utils.log
import
Log
root
.
setLevel
(
logging
.
DEBUG
)
logger
=
Log
(
__name__
).
getlog
()
format
=
'[%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s'
formatter
=
logging
.
Formatter
(
fmt
=
format
,
datefmt
=
'%Y/%m/%d %H:%M:%S'
)
stream_handler
=
logging
.
StreamHandler
()
stream_handler
.
setLevel
(
logging
.
INFO
)
stream_handler
.
setFormatter
(
formatter
)
root
.
addHandler
(
stream_handler
)
save_path
=
'global.log'
file_handler
=
logging
.
FileHandler
(
save_path
)
file_handler
.
setLevel
(
logging
.
DEBUG
)
file_handler
.
setFormatter
(
formatter
)
root
.
addHandler
(
file_handler
)
# stop propagate for propagating may print
# log multiple times
root
.
propagate
=
False
logger
=
logging
.
getLogger
(
__name__
)
########### hcak logging #############
########### hcak logging #############
logger
.
warn
=
logg
ing
.
warning
logger
.
warn
=
logg
er
.
warning
########### hcak paddle #############
########### hcak paddle #############
paddle
.
bool
=
'bool'
paddle
.
bool
=
'bool'
...
...
deepspeech/exps/deepspeech2/model.py
浏览文件 @
676ebcdf
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"""Contains DeepSpeech2 model."""
"""Contains DeepSpeech2 model."""
import
time
import
time
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
collections
import
defaultdict
from
collections
import
defaultdict
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -38,7 +38,7 @@ from deepspeech.io.dataset import ManifestDataset
...
@@ -38,7 +38,7 @@ from deepspeech.io.dataset import ManifestDataset
from
deepspeech.models.deepspeech2
import
DeepSpeech2Model
from
deepspeech.models.deepspeech2
import
DeepSpeech2Model
from
deepspeech.models.deepspeech2
import
DeepSpeech2InferModel
from
deepspeech.models.deepspeech2
import
DeepSpeech2InferModel
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
class
DeepSpeech2Trainer
(
Trainer
):
class
DeepSpeech2Trainer
(
Trainer
):
...
...
deepspeech/exps/u2/model.py
浏览文件 @
676ebcdf
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
sys
import
sys
import
time
import
time
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
collections
import
defaultdict
from
collections
import
defaultdict
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -41,7 +41,7 @@ from deepspeech.io.dataset import ManifestDataset
...
@@ -41,7 +41,7 @@ from deepspeech.io.dataset import ManifestDataset
from
deepspeech.models.u2
import
U2Model
from
deepspeech.models.u2
import
U2Model
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
class
U2Trainer
(
Trainer
):
class
U2Trainer
(
Trainer
):
...
...
deepspeech/frontend/augmentor/spec_augment.py
浏览文件 @
676ebcdf
...
@@ -12,12 +12,12 @@
...
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Contains the volume perturb augmentation model."""
"""Contains the volume perturb augmentation model."""
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
deepspeech.frontend.augmentor.base
import
AugmentorBase
from
deepspeech.frontend.augmentor.base
import
AugmentorBase
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
class
SpecAugmentor
(
AugmentorBase
):
class
SpecAugmentor
(
AugmentorBase
):
...
...
deepspeech/frontend/utility.py
浏览文件 @
676ebcdf
...
@@ -16,9 +16,9 @@ import numpy as np
...
@@ -16,9 +16,9 @@ import numpy as np
import
math
import
math
import
json
import
json
import
codecs
import
codecs
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
__all__
=
[
"load_cmvn"
,
"read_manifest"
,
"rms_to_db"
,
"rms_to_dbfs"
,
"max_dbfs"
,
"load_cmvn"
,
"read_manifest"
,
"rms_to_db"
,
"rms_to_dbfs"
,
"max_dbfs"
,
...
...
deepspeech/io/collator.py
浏览文件 @
676ebcdf
...
@@ -12,16 +12,16 @@
...
@@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
deepspeech.io.utility
import
pad_sequence
from
deepspeech.io.utility
import
pad_sequence
from
deepspeech.frontend.utility
import
IGNORE_ID
from
deepspeech.frontend.utility
import
IGNORE_ID
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
"SpeechCollator"
]
__all__
=
[
"SpeechCollator"
]
logger
=
Log
(
__name__
).
getlog
()
class
SpeechCollator
():
class
SpeechCollator
():
def
__init__
(
self
,
keep_transcription_text
=
True
):
def
__init__
(
self
,
keep_transcription_text
=
True
):
...
...
deepspeech/io/dataset.py
浏览文件 @
676ebcdf
...
@@ -16,7 +16,7 @@ import time
...
@@ -16,7 +16,7 @@ import time
import
io
import
io
import
random
import
random
import
tarfile
import
tarfile
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Optional
from
typing
import
Optional
from
yacs.config
import
CfgNode
from
yacs.config
import
CfgNode
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -29,12 +29,12 @@ from deepspeech.frontend.featurizer.speech_featurizer import SpeechFeaturizer
...
@@ -29,12 +29,12 @@ from deepspeech.frontend.featurizer.speech_featurizer import SpeechFeaturizer
from
deepspeech.frontend.speech
import
SpeechSegment
from
deepspeech.frontend.speech
import
SpeechSegment
from
deepspeech.frontend.normalizer
import
FeatureNormalizer
from
deepspeech.frontend.normalizer
import
FeatureNormalizer
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
__all__
=
[
"ManifestDataset"
,
"ManifestDataset"
,
]
]
logger
=
Log
(
__name__
).
getlog
()
class
ManifestDataset
(
Dataset
):
class
ManifestDataset
(
Dataset
):
@
classmethod
@
classmethod
...
...
deepspeech/io/sampler.py
浏览文件 @
676ebcdf
...
@@ -13,20 +13,20 @@
...
@@ -13,20 +13,20 @@
# limitations under the License.
# limitations under the License.
import
math
import
math
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
paddle.io
import
BatchSampler
from
paddle.io
import
BatchSampler
from
paddle.io
import
DistributedBatchSampler
from
paddle.io
import
DistributedBatchSampler
from
paddle
import
distributed
as
dist
from
paddle
import
distributed
as
dist
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
__all__
=
[
"SortagradDistributedBatchSampler"
,
"SortagradDistributedBatchSampler"
,
"SortagradBatchSampler"
,
"SortagradBatchSampler"
,
]
]
logger
=
Log
(
__name__
).
getlog
()
def
_batch_shuffle
(
indices
,
batch_size
,
epoch
,
clipped
=
False
):
def
_batch_shuffle
(
indices
,
batch_size
,
epoch
,
clipped
=
False
):
"""Put similarly-sized instances into minibatches for better efficiency
"""Put similarly-sized instances into minibatches for better efficiency
...
...
deepspeech/io/utility.py
浏览文件 @
676ebcdf
...
@@ -12,14 +12,14 @@
...
@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
typing
import
List
from
typing
import
List
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
"pad_sequence"
]
__all__
=
[
"pad_sequence"
]
logger
=
Log
(
__name__
).
getlog
()
def
pad_sequence
(
sequences
:
List
[
np
.
ndarray
],
def
pad_sequence
(
sequences
:
List
[
np
.
ndarray
],
batch_first
:
bool
=
True
,
batch_first
:
bool
=
True
,
...
...
deepspeech/models/deepspeech2.py
浏览文件 @
676ebcdf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Deepspeech2 ASR Model"""
"""Deepspeech2 ASR Model"""
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Optional
from
typing
import
Optional
from
yacs.config
import
CfgNode
from
yacs.config
import
CfgNode
...
@@ -26,7 +26,7 @@ from deepspeech.modules.ctc import CTCDecoder
...
@@ -26,7 +26,7 @@ from deepspeech.modules.ctc import CTCDecoder
from
deepspeech.utils
import
checkpoint
from
deepspeech.utils
import
checkpoint
from
deepspeech.utils
import
layer_tools
from
deepspeech.utils
import
layer_tools
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'DeepSpeech2Model'
]
__all__
=
[
'DeepSpeech2Model'
]
...
...
deepspeech/models/u2.py
浏览文件 @
676ebcdf
...
@@ -19,7 +19,7 @@ Unified Streaming and Non-streaming Two-pass End-to-end Model for Speech Recogni
...
@@ -19,7 +19,7 @@ Unified Streaming and Non-streaming Two-pass End-to-end Model for Speech Recogni
import
time
import
time
import
sys
import
sys
from
collections
import
defaultdict
from
collections
import
defaultdict
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
yacs.config
import
CfgNode
from
yacs.config
import
CfgNode
from
typing
import
List
,
Optional
,
Tuple
,
Dict
from
typing
import
List
,
Optional
,
Tuple
,
Dict
...
@@ -50,7 +50,7 @@ from deepspeech.utils.tensor_utils import th_accuracy
...
@@ -50,7 +50,7 @@ from deepspeech.utils.tensor_utils import th_accuracy
from
deepspeech.utils.tensor_utils
import
pad_sequence
from
deepspeech.utils.tensor_utils
import
pad_sequence
from
deepspeech.utils.ctc_utils
import
remove_duplicates_and_blank
from
deepspeech.utils.ctc_utils
import
remove_duplicates_and_blank
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"U2Model"
,
"U2InferModel"
]
__all__
=
[
"U2Model"
,
"U2InferModel"
]
...
...
deepspeech/modules/activation.py
浏览文件 @
676ebcdf
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
collections
import
OrderedDict
from
collections
import
OrderedDict
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"get_activation"
,
"brelu"
,
"LinearGLUBlock"
,
"ConvGLUBlock"
]
__all__
=
[
"get_activation"
,
"brelu"
,
"LinearGLUBlock"
,
"ConvGLUBlock"
]
...
...
deepspeech/modules/attention.py
浏览文件 @
676ebcdf
...
@@ -13,14 +13,14 @@
...
@@ -13,14 +13,14 @@
# limitations under the License.
# limitations under the License.
"""Multi-Head Attention layer definition."""
"""Multi-Head Attention layer definition."""
import
math
import
math
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Optional
,
Tuple
from
typing
import
Optional
,
Tuple
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
from
paddle.nn
import
initializer
as
I
from
paddle.nn
import
initializer
as
I
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"MultiHeadedAttention"
,
"RelPositionMultiHeadedAttention"
]
__all__
=
[
"MultiHeadedAttention"
,
"RelPositionMultiHeadedAttention"
]
...
...
deepspeech/modules/cmvn.py
浏览文件 @
676ebcdf
...
@@ -12,12 +12,12 @@
...
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'GlobalCMVN'
]
__all__
=
[
'GlobalCMVN'
]
...
...
deepspeech/modules/conformer_convolution.py
浏览文件 @
676ebcdf
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
from
typing
import
Optional
,
Tuple
from
typing
import
Optional
,
Tuple
from
typeguard
import
check_argument_types
from
typeguard
import
check_argument_types
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'ConvolutionModule'
]
__all__
=
[
'ConvolutionModule'
]
...
...
deepspeech/modules/conv.py
浏览文件 @
676ebcdf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
paddle
import
nn
from
paddle
import
nn
from
paddle.nn
import
functional
as
F
from
paddle.nn
import
functional
as
F
...
@@ -20,7 +20,7 @@ from paddle.nn import functional as F
...
@@ -20,7 +20,7 @@ from paddle.nn import functional as F
from
deepspeech.modules.mask
import
sequence_mask
from
deepspeech.modules.mask
import
sequence_mask
from
deepspeech.modules.activation
import
brelu
from
deepspeech.modules.activation
import
brelu
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'ConvStack'
,
"conv_output_size"
]
__all__
=
[
'ConvStack'
,
"conv_output_size"
]
...
...
deepspeech/modules/ctc.py
浏览文件 @
676ebcdf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typeguard
import
check_argument_types
from
typeguard
import
check_argument_types
import
paddle
import
paddle
...
@@ -26,7 +26,7 @@ from deepspeech.decoders.swig_wrapper import Scorer
...
@@ -26,7 +26,7 @@ from deepspeech.decoders.swig_wrapper import Scorer
from
deepspeech.decoders.swig_wrapper
import
ctc_greedy_decoder
from
deepspeech.decoders.swig_wrapper
import
ctc_greedy_decoder
from
deepspeech.decoders.swig_wrapper
import
ctc_beam_search_decoder_batch
from
deepspeech.decoders.swig_wrapper
import
ctc_beam_search_decoder_batch
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'CTCDecoder'
]
__all__
=
[
'CTCDecoder'
]
...
...
deepspeech/modules/decoder.py
浏览文件 @
676ebcdf
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"""Decoder definition."""
"""Decoder definition."""
from
typing
import
Tuple
,
List
,
Optional
from
typing
import
Tuple
,
List
,
Optional
from
typeguard
import
check_argument_types
from
typeguard
import
check_argument_types
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
...
@@ -26,7 +26,7 @@ from deepspeech.modules.positionwise_feed_forward import PositionwiseFeedForward
...
@@ -26,7 +26,7 @@ from deepspeech.modules.positionwise_feed_forward import PositionwiseFeedForward
from
deepspeech.modules.mask
import
subsequent_mask
from
deepspeech.modules.mask
import
subsequent_mask
from
deepspeech.modules.mask
import
make_non_pad_mask
from
deepspeech.modules.mask
import
make_non_pad_mask
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"TransformerDecoder"
]
__all__
=
[
"TransformerDecoder"
]
...
...
deepspeech/modules/decoder_layer.py
浏览文件 @
676ebcdf
...
@@ -13,12 +13,12 @@
...
@@ -13,12 +13,12 @@
# limitations under the License.
# limitations under the License.
"""Decoder self-attention layer definition."""
"""Decoder self-attention layer definition."""
from
typing
import
Optional
,
Tuple
from
typing
import
Optional
,
Tuple
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"DecoderLayer"
]
__all__
=
[
"DecoderLayer"
]
...
...
deepspeech/modules/embedding.py
浏览文件 @
676ebcdf
...
@@ -14,13 +14,13 @@
...
@@ -14,13 +14,13 @@
"""Positonal Encoding Module."""
"""Positonal Encoding Module."""
import
math
import
math
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Tuple
from
typing
import
Tuple
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"PositionalEncoding"
,
"RelPositionalEncoding"
]
__all__
=
[
"PositionalEncoding"
,
"RelPositionalEncoding"
]
...
...
deepspeech/modules/encoder.py
浏览文件 @
676ebcdf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Encoder definition."""
"""Encoder definition."""
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Tuple
,
List
,
Optional
from
typing
import
Tuple
,
List
,
Optional
from
typeguard
import
check_argument_types
from
typeguard
import
check_argument_types
...
@@ -35,7 +35,7 @@ from deepspeech.modules.mask import make_non_pad_mask
...
@@ -35,7 +35,7 @@ from deepspeech.modules.mask import make_non_pad_mask
from
deepspeech.modules.mask
import
add_optional_chunk_mask
from
deepspeech.modules.mask
import
add_optional_chunk_mask
from
deepspeech.modules.activation
import
get_activation
from
deepspeech.modules.activation
import
get_activation
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"BaseEncoder"
,
'TransformerEncoder'
,
"ConformerEncoder"
]
__all__
=
[
"BaseEncoder"
,
'TransformerEncoder'
,
"ConformerEncoder"
]
...
...
deepspeech/modules/encoder_layer.py
浏览文件 @
676ebcdf
...
@@ -13,12 +13,12 @@
...
@@ -13,12 +13,12 @@
# limitations under the License.
# limitations under the License.
"""Encoder self-attention layer definition."""
"""Encoder self-attention layer definition."""
from
typing
import
Optional
,
Tuple
from
typing
import
Optional
,
Tuple
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"TransformerEncoderLayer"
,
"ConformerEncoderLayer"
]
__all__
=
[
"TransformerEncoderLayer"
,
"ConformerEncoderLayer"
]
...
...
deepspeech/modules/loss.py
浏览文件 @
676ebcdf
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
from
paddle.nn
import
functional
as
F
from
paddle.nn
import
functional
as
F
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'CTCLoss'
,
"LabelSmoothingLoss"
]
__all__
=
[
'CTCLoss'
,
"LabelSmoothingLoss"
]
...
...
deepspeech/modules/mask.py
浏览文件 @
676ebcdf
...
@@ -12,11 +12,11 @@
...
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
__all__
=
[
'sequence_mask'
,
"make_pad_mask"
,
"make_non_pad_mask"
,
"subsequent_mask"
,
'sequence_mask'
,
"make_pad_mask"
,
"make_non_pad_mask"
,
"subsequent_mask"
,
...
...
deepspeech/modules/positionwise_feed_forward.py
浏览文件 @
676ebcdf
...
@@ -12,12 +12,12 @@
...
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Positionwise feed forward layer definition."""
"""Positionwise feed forward layer definition."""
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"PositionwiseFeedForward"
]
__all__
=
[
"PositionwiseFeedForward"
]
...
...
deepspeech/modules/rnn.py
浏览文件 @
676ebcdf
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
import
math
import
math
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
...
@@ -23,7 +23,7 @@ from paddle.nn import initializer as I
...
@@ -23,7 +23,7 @@ from paddle.nn import initializer as I
from
deepspeech.modules.mask
import
sequence_mask
from
deepspeech.modules.mask
import
sequence_mask
from
deepspeech.modules.activation
import
brelu
from
deepspeech.modules.activation
import
brelu
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
'RNNStack'
]
__all__
=
[
'RNNStack'
]
...
...
deepspeech/modules/subsampling.py
浏览文件 @
676ebcdf
...
@@ -14,14 +14,14 @@
...
@@ -14,14 +14,14 @@
"""Subsampling layer definition."""
"""Subsampling layer definition."""
from
typing
import
Tuple
from
typing
import
Tuple
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
from
deepspeech.modules.embedding
import
PositionalEncoding
from
deepspeech.modules.embedding
import
PositionalEncoding
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
__all__
=
[
"LinearNoSubsampling"
,
"Conv2dSubsampling4"
,
"Conv2dSubsampling6"
,
"LinearNoSubsampling"
,
"Conv2dSubsampling4"
,
"Conv2dSubsampling6"
,
...
...
deepspeech/training/gradclip.py
浏览文件 @
676ebcdf
...
@@ -12,17 +12,17 @@
...
@@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
paddle
import
paddle
from
paddle.fluid.dygraph
import
base
as
imperative_base
from
paddle.fluid.dygraph
import
base
as
imperative_base
from
paddle.fluid
import
layers
from
paddle.fluid
import
layers
from
paddle.fluid
import
core
from
paddle.fluid
import
core
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
"ClipGradByGlobalNormWithLog"
]
__all__
=
[
"ClipGradByGlobalNormWithLog"
]
logger
=
Log
(
__name__
).
getlog
()
class
ClipGradByGlobalNormWithLog
(
paddle
.
nn
.
ClipGradByGlobalNorm
):
class
ClipGradByGlobalNormWithLog
(
paddle
.
nn
.
ClipGradByGlobalNorm
):
def
__init__
(
self
,
clip_norm
):
def
__init__
(
self
,
clip_norm
):
...
...
deepspeech/training/scheduler.py
浏览文件 @
676ebcdf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Union
from
typing
import
Union
from
typeguard
import
check_argument_types
from
typeguard
import
check_argument_types
...
@@ -20,7 +20,7 @@ from paddle.optimizer.lr import LRScheduler
...
@@ -20,7 +20,7 @@ from paddle.optimizer.lr import LRScheduler
__all__
=
[
"WarmupLR"
]
__all__
=
[
"WarmupLR"
]
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
class
WarmupLR
(
LRScheduler
):
class
WarmupLR
(
LRScheduler
):
...
...
deepspeech/training/trainer.py
浏览文件 @
676ebcdf
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
import
time
import
time
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
pathlib
import
Path
from
pathlib
import
Path
import
paddle
import
paddle
...
@@ -25,7 +25,7 @@ from deepspeech.utils import mp_tools
...
@@ -25,7 +25,7 @@ from deepspeech.utils import mp_tools
__all__
=
[
"Trainer"
]
__all__
=
[
"Trainer"
]
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
class
Trainer
():
class
Trainer
():
...
...
deepspeech/utils/checkpoint.py
浏览文件 @
676ebcdf
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
import
os
import
os
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
re
import
re
import
json
import
json
from
typing
import
Union
from
typing
import
Union
...
@@ -24,7 +24,7 @@ from paddle.optimizer import Optimizer
...
@@ -24,7 +24,7 @@ from paddle.optimizer import Optimizer
from
deepspeech.utils
import
mp_tools
from
deepspeech.utils
import
mp_tools
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"load_parameters"
,
"save_parameters"
]
__all__
=
[
"load_parameters"
,
"save_parameters"
]
...
...
deepspeech/utils/ctc_utils.py
浏览文件 @
676ebcdf
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
import
numpy
as
np
import
numpy
as
np
from
typing
import
List
from
typing
import
List
import
paddle
import
paddle
logger
=
logging
.
getLogger
(
__name__
)
logger
=
Log
(
__name__
).
getlog
(
)
__all__
=
[
"forced_align"
,
"remove_duplicates_and_blank"
,
"insert_blank"
]
__all__
=
[
"forced_align"
,
"remove_duplicates_and_blank"
,
"insert_blank"
]
...
...
deepspeech/utils/log.py
0 → 100644
浏览文件 @
676ebcdf
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
logging
import
os
class
Log
():
def
__init__
(
self
,
logger
=
None
,
log_cate
=
'global'
):
self
.
logger
=
logging
.
getLogger
(
logger
)
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
file_dir
=
os
.
getcwd
()
+
'/log'
if
not
os
.
path
.
exists
(
file_dir
):
os
.
mkdir
(
file_dir
)
self
.
log_path
=
file_dir
self
.
log_name
=
self
.
log_path
+
"/"
+
log_cate
+
'.log'
fh
=
logging
.
FileHandler
(
self
.
log_name
)
fh
.
setLevel
(
logging
.
DEBUG
)
ch
=
logging
.
StreamHandler
()
ch
.
setLevel
(
logging
.
INFO
)
format
=
'[%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s'
formatter
=
logging
.
Formatter
(
fmt
=
format
,
datefmt
=
'%Y/%m/%d %H:%M:%S'
)
fh
.
setFormatter
(
formatter
)
ch
.
setFormatter
(
formatter
)
self
.
logger
.
addHandler
(
fh
)
self
.
logger
.
addHandler
(
ch
)
# stop propagate for propagating may print
# log multiple times
# self.logger.propagate = False
fh
.
close
()
ch
.
close
()
def
getlog
(
self
):
return
self
.
logger
deepspeech/utils/tensor_utils.py
浏览文件 @
676ebcdf
...
@@ -12,15 +12,15 @@
...
@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Unility functions for Transformer."""
"""Unility functions for Transformer."""
import
loggin
g
from
deepspeech.utils.log
import
Lo
g
from
typing
import
Tuple
,
List
from
typing
import
Tuple
,
List
import
paddle
import
paddle
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
"pad_sequence"
,
"add_sos_eos"
,
"th_accuracy"
]
__all__
=
[
"pad_sequence"
,
"add_sos_eos"
,
"th_accuracy"
]
logger
=
Log
(
__name__
).
getlog
()
def
pad_sequence
(
sequences
:
List
[
paddle
.
Tensor
],
def
pad_sequence
(
sequences
:
List
[
paddle
.
Tensor
],
batch_first
:
bool
=
False
,
batch_first
:
bool
=
False
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录