A good amount of code for neural networks used for speech recognition are included for the first time in a single file airbus_attention_vtlp_CTC.py in commit 1857440. Despite the obvious fact that the code needs refactoring, it's helpful to lay out its major violations of coding standard so we can work towards a better solution. This issue will also serve as a cheatsheet of coding practices that all of us should maintain.
All other changes specific to the ASR script are reported in "Debug ASR Main Script". Report only audlib.nn-related changes here.
Coding Practices
Functional file layouts. A long file containing a wide range of functionalities should be broken down into small files, within each all functions could be summarized by one short file name.
Lint before commit. Use linters like pyflakes to check for PEP8 style violations. It's cheap to do and yet very effective.
Place top-level utilities in egs or bin. Generic CLI scripts can be put in bin, whereas specialized applications can be put in egs.
Minimize external dependencies.
It's okay to include dependencies that offer major functionalities and are in active development, such as torch.
It's not okay to include dependencies that either offer little or are no longer supported, unless there is a compelling reason (e.g. help rolling out a major feature) to do so.
Write docstring in double quote. Never write in single quote or block comment. I have been following Numpy's docstring standard.
Explicit function parameters. It's better to have
MLP(linear_dim, input_dim, output_dim)
than referencing args.linear_dim inside
MLP(args, input_dim, output_dim)
Explicit class/function names. It's better to have PyramidalLSTM than pLSTM. Similarly, EncoderModel needs to be more descriptive.
Static methods for class-specific functions.
More will be added as refactoring work progresses.
Introduction
A good amount of code for neural networks used for speech recognition are included for the first time in a single file
airbus_attention_vtlp_CTC.py
in commit 1857440. Despite the obvious fact that the code needs refactoring, it's helpful to lay out its major violations of coding standard so we can work towards a better solution. This issue will also serve as a cheatsheet of coding practices that all of us should maintain.All other changes specific to the ASR script are reported in "Debug ASR Main Script". Report only
audlib.nn
-related changes here.Coding Practices
Functional file layouts. A long file containing a wide range of functionalities should be broken down into small files, within each all functions could be summarized by one short file name.
Lint before commit. Use linters like
pyflakes
to check for PEP8 style violations. It's cheap to do and yet very effective.Place top-level utilities in
egs
orbin
. Generic CLI scripts can be put inbin
, whereas specialized applications can be put inegs
.Minimize external dependencies.
torch
.Write docstring in double quote. Never write in single quote or block comment. I have been following
Numpy
's docstring standard.Explicit function parameters. It's better to have
MLP(linear_dim, input_dim, output_dim)
than referencing
args.linear_dim
insideMLP(args, input_dim, output_dim)
Explicit class/function names. It's better to have
PyramidalLSTM
thanpLSTM
. Similarly,EncoderModel
needs to be more descriptive.Static methods for class-specific functions.
More will be added as refactoring work progresses.
Major Changes in Commit 05eb1ec
By @raymondxyy.
MLP
fromto
Updated usage of MLP accordingly.
AdvancedLSTMCell
,AdvancedLSTM
, and other generic NNs toaudlib.nn.nn
.to_tensor
to callable to be consistent with PyTorch.TODOs
audlib.nn.nn
.