-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Squeezeformer #1447
Merged
Merged
Squeezeformer #1447
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
23c4f99
[init] enable SqueezeformerEncoder
7c24031
[update] enable Squeezeformer training
76ac435
[update] README.md
b291d1e
fix formatting issues
yygle 6a36c23
fix formatting issues
yygle 139fc36
fix formatting issues
yygle 084c843
fix formatting issues
yygle 1f4a8b3
[update] change residual connection & add copyrights
yygle 0558fbb
fix formatting issues
yygle 0264049
[update] enlarge adaptive scale dimensions
yygle be2f56e
fix formatting issues
yygle ba6825c
fix adaptive scale bugs
yygle 89f133e
[update] encoder.py(fix init weights bugs) and README.md
yygle 78b8077
[update] initialization for input projection
yygle 76fbcf2
fix formatting issues
yygle cefa4cd
fix formatting issues
yygle c2f2a05
[update] time reduction layer with conv1d and conv2d
yygle ba7ed74
fix formatting issues
yygle 027c85c
[update] operators
yygle ed342f2
[update] experiment results & code format
yygle ac4013c
[update] experiment results
yygle 6592ae3
[update] streaming support & results, dw_stride trigger
yygle 67e260a
fix formatting issue
yygle 5973352
fix formatting issue
yygle 08c49aa
fix formatting issue
yygle d777305
fix formatting issue
yygle cd82d89
[update] SqueezeFormer Large Results
yygle 3c55dde
fix formatting issues
yygle 0824e56
fix format issues
yygle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# network architecture | ||
# encoder related | ||
encoder: squeezeformer | ||
encoder_conf: | ||
encoder_dim: 256 | ||
output_size: 256 # dimension of attention | ||
attention_heads: 4 | ||
num_blocks: 12 # the number of encoder blocks | ||
reduce_idx: 5 | ||
recover_idx: 11 | ||
pos_enc_layer_type: 'rel_pos' | ||
time_reduction_layer_type: 'conv1d' | ||
feed_forward_expansion_factor: 4 | ||
input_dropout_rate: 0.1 | ||
feed_forward_dropout_rate: 0.1 | ||
attention_dropout_rate: 0.1 | ||
cnn_module_kernel: 31 | ||
cnn_norm_type: layer_norm | ||
adaptive_scale: true | ||
normalize_before: false | ||
|
||
# decoder related | ||
decoder: transformer | ||
decoder_conf: | ||
attention_heads: 4 | ||
linear_units: 2048 | ||
num_blocks: 6 | ||
dropout_rate: 0.1 | ||
positional_dropout_rate: 0.1 | ||
self_attention_dropout_rate: 0.0 | ||
src_attention_dropout_rate: 0.0 | ||
|
||
# hybrid CTC/attention | ||
model_conf: | ||
ctc_weight: 0.3 | ||
lsm_weight: 0.1 # label smoothing option | ||
length_normalized_loss: false | ||
|
||
# dataset related | ||
dataset_conf: | ||
filter_conf: | ||
max_length: 2000 | ||
min_length: 50 | ||
token_max_length: 400 | ||
token_min_length: 1 | ||
min_output_input_ratio: 0.0005 | ||
max_output_input_ratio: 0.1 | ||
resample_conf: | ||
resample_rate: 16000 | ||
speed_perturb: true | ||
fbank_conf: | ||
num_mel_bins: 80 | ||
frame_shift: 10 | ||
frame_length: 25 | ||
dither: 0.1 | ||
spec_aug: true | ||
spec_aug_conf: | ||
num_t_mask: 2 | ||
num_f_mask: 2 | ||
max_t: 50 | ||
max_f: 10 | ||
shuffle: true | ||
shuffle_conf: | ||
shuffle_size: 1500 | ||
sort: true | ||
sort_conf: | ||
sort_size: 500 # sort_size should be less than shuffle_size | ||
batch_conf: | ||
batch_type: 'static' # static or dynamic | ||
batch_size: 12 | ||
|
||
grad_clip: 5 | ||
accum_grad: 4 | ||
max_epoch: 120 | ||
log_interval: 100 | ||
|
||
optim: adamw | ||
optim_conf: | ||
lr: 1.e-3 | ||
weight_decay: 4.e-5 | ||
|
||
scheduler: NoamHoldAnnealing | ||
scheduler_conf: | ||
warmup_ratio: 0.2 | ||
hold_ratio: 0.3 | ||
max_steps: 87960 | ||
decay_rate: 1.0 | ||
min_lr: 1.e-5 |
96 changes: 96 additions & 0 deletions
96
examples/librispeech/s0/conf/train_squeezeformer_bidecoder_large.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# network architecture | ||
# encoder related | ||
encoder: squeezeformer | ||
encoder_conf: | ||
encoder_dim: 512 | ||
output_size: 512 # dimension of attention | ||
attention_heads: 8 | ||
num_blocks: 12 # the number of encoder blocks | ||
reduce_idx: 5 | ||
recover_idx: 11 | ||
feed_forward_expansion_factor: 4 | ||
input_dropout_rate: 0.1 | ||
feed_forward_dropout_rate: 0.1 | ||
attention_dropout_rate: 0.1 | ||
cnn_module_kernel: 31 | ||
cnn_norm_type: batch_norm | ||
adaptive_scale: true | ||
normalize_before: false | ||
|
||
# decoder related | ||
decoder: bitransformer | ||
decoder_conf: | ||
attention_heads: 8 | ||
linear_units: 2048 | ||
num_blocks: 3 | ||
r_num_blocks: 3 | ||
dropout_rate: 0.1 | ||
positional_dropout_rate: 0.1 | ||
self_attention_dropout_rate: 0.1 | ||
src_attention_dropout_rate: 0.1 | ||
|
||
# hybrid CTC/attention | ||
model_conf: | ||
ctc_weight: 0.3 | ||
lsm_weight: 0.1 # label smoothing option | ||
length_normalized_loss: false | ||
reverse_weight: 0.3 | ||
|
||
# dataset related | ||
dataset_conf: | ||
syncbn: true | ||
filter_conf: | ||
max_length: 2000 | ||
min_length: 50 | ||
token_max_length: 400 | ||
token_min_length: 1 | ||
min_output_input_ratio: 0.0005 | ||
max_output_input_ratio: 0.1 | ||
resample_conf: | ||
resample_rate: 16000 | ||
speed_perturb: true | ||
fbank_conf: | ||
num_mel_bins: 80 | ||
frame_shift: 10 | ||
frame_length: 25 | ||
dither: 1.0 | ||
spec_aug: true | ||
spec_aug_conf: | ||
num_t_mask: 3 | ||
num_f_mask: 2 | ||
max_t: 100 | ||
max_f: 27 | ||
max_w: 80 | ||
# warp_for_time: true | ||
spec_sub: true | ||
spec_sub_conf: | ||
num_t_sub: 3 | ||
max_t: 30 | ||
shuffle: true | ||
shuffle_conf: | ||
shuffle_size: 1500 | ||
sort: true | ||
sort_conf: | ||
sort_size: 500 # sort_size should be less than shuffle_size | ||
batch_conf: | ||
batch_type: 'static' # static or dynamic | ||
batch_size: 12 | ||
|
||
grad_clip: 5 | ||
accum_grad: 4 | ||
max_epoch: 500 | ||
log_interval: 100 | ||
|
||
optim: adamw | ||
optim_conf: | ||
lr: 1.e-3 | ||
weight_decay: 4.e-5 | ||
|
||
scheduler: NoamHoldAnnealing | ||
scheduler_conf: | ||
warmup_ratio: 0.2 | ||
hold_ratio: 0.3 | ||
max_steps: 87960 | ||
decay_rate: 1.0 | ||
min_lr: 1.e-5 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
与这个相关的代码似乎没有提上来?syncbn的转换似乎是可以在Train.py中调用torch api一键完成:
这里把他放到dataset_conf域是处于什么考量呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synbn不能直接在wenet中实现主要是因为数据不均衡带来的进程等待,完整的实现中我考虑了两种情况,1. 即DDP数据不分割(每个进程更新完整数据集),以及2. 分割数据集,drop掉多余部分,因此在我这个版本实现中,将这个变量与数据集绑定在了一起。 这个部分的代码因为与Squeezeformer的算法更新无关,属于工程优化范畴,因此会另提交PR更新。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,那我先合并,你继续优化和迭代。