forked from alibaba/Alibaba-MIT-Speech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlibaba_MIT_Speech_DFSMN.patch
4027 lines (3971 loc) · 155 KB
/
Alibaba_MIT_Speech_DFSMN.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 02cce315a6b6cb7f45dd92673e9203d7c3d1b242 Mon Sep 17 00:00:00 2001
From: "sly.zsl" <[email protected]>
Date: Mon, 2 Jul 2018 19:10:46 +0800
Subject: [PATCH] add DFSMN related codes
---
egs/librispeech/s5/RESULTS | 114 +++++
egs/librispeech/s5/conf/fbank.conf | 6 +
egs/librispeech/s5/local/nnet/DFSMN_L.proto | 23 ++
egs/librispeech/s5/local/nnet/DFSMN_M.proto | 19 +
egs/librispeech/s5/local/nnet/DFSMN_S.proto | 19 +
egs/librispeech/s5/local/nnet/run_fsmn_ivector.sh | 142 +++++++
egs/librispeech/s5/run.sh | 12 +-
egs/wsj/s5/steps/nnet/train_faster.sh | 481 ++++++++++++++++++++++
egs/wsj/s5/steps/nnet/train_faster_scheduler.sh | 221 ++++++++++
src/cudamatrix/cu-kernels-ansi.h | 32 ++
src/cudamatrix/cu-kernels.cu | 335 +++++++++++++++
src/cudamatrix/cu-kernels.h | 75 ++++
src/cudamatrix/cu-matrix.cc | 209 +++++++++-
src/cudamatrix/cu-matrix.h | 33 +-
src/featbin/Makefile | 2 +-
src/featbin/append-ivector-to-feats.cc | 231 +++++++++++
src/nnet/nnet-affine-transform.h | 28 +-
src/nnet/nnet-component.cc | 22 +
src/nnet/nnet-component.h | 9 +-
src/nnet/nnet-deep-fsmn.h | 350 ++++++++++++++++
src/nnet/nnet-fsmn.h | 211 ++++++++++
src/nnet/nnet-linear-transform.h | 20 +-
src/nnet/nnet-nnet.cc | 25 ++
src/nnet/nnet-nnet.h | 4 +
src/nnet/nnet-uni-deep-fsmn.h | 319 ++++++++++++++
src/nnet/nnet-uni-fsmn.h | 175 ++++++++
src/nnetbin/Makefile | 3 +-
src/nnetbin/nnet-forward.cc | 6 +
src/nnetbin/nnet-train-fsmn-streams.cc | 420 +++++++++++++++++++
src/nnetbin/nnet-train-mmi-sequential.cc | 6 +
src/nnetbin/nnet-train-mpe-sequential.cc | 6 +
31 files changed, 3534 insertions(+), 24 deletions(-)
create mode 100644 egs/librispeech/s5/conf/fbank.conf
create mode 100644 egs/librispeech/s5/local/nnet/DFSMN_L.proto
create mode 100644 egs/librispeech/s5/local/nnet/DFSMN_M.proto
create mode 100644 egs/librispeech/s5/local/nnet/DFSMN_S.proto
create mode 100644 egs/librispeech/s5/local/nnet/run_fsmn_ivector.sh
create mode 100755 egs/wsj/s5/steps/nnet/train_faster.sh
create mode 100755 egs/wsj/s5/steps/nnet/train_faster_scheduler.sh
create mode 100644 src/featbin/append-ivector-to-feats.cc
create mode 100644 src/nnet/nnet-deep-fsmn.h
create mode 100644 src/nnet/nnet-fsmn.h
create mode 100644 src/nnet/nnet-uni-deep-fsmn.h
create mode 100644 src/nnet/nnet-uni-fsmn.h
create mode 100644 src/nnetbin/nnet-train-fsmn-streams.cc
diff --git a/egs/librispeech/s5/RESULTS b/egs/librispeech/s5/RESULTS
index 32b39b2..f06421f 100644
--- a/egs/librispeech/s5/RESULTS
+++ b/egs/librispeech/s5/RESULTS
@@ -681,3 +681,117 @@
%WER 14.64 [ 7664 / 52343, 818 ins, 956 del, 5890 sub ] exp/chain/tdnn_6z_sp_smbr/decode_test_other_tgsmall_epoch3/wer_13_0.0
%WER 14.70 [ 7696 / 52343, 835 ins, 945 del, 5916 sub ] exp/chain/tdnn_6z_sp_smbr/decode_test_other_tgsmall_epoch6/wer_13_0.0
%WER 14.75 [ 7722 / 52343, 892 ins, 849 del, 5981 sub ] exp/chain/tdnn_6z_sp_smbr/decode_test_other_tgsmall_epoch9/wer_12_0.0
+
+# Results with nnet DFMSN_S + CE
+# local/nnet/run_fsmn_ivector.sh DFSMN_S
+# Training on the "cleaned" data
+%WER 3.97 [ 2160 / 54402, 264 ins, 233 del, 1663 sub ] exp/tri7b_DFSMN_S/decode_fglarge_dev_clean/wer_10_1.0
+%WER 4.10 [ 2230 / 54402, 270 ins, 242 del, 1718 sub ] exp/tri7b_DFSMN_S/decode_tglarge_dev_clean/wer_12_0.5
+%WER 5.06 [ 2752 / 54402, 274 ins, 360 del, 2118 sub ] exp/tri7b_DFSMN_S/decode_tgmed_dev_clean/wer_13_0.5
+%WER 5.55 [ 3022 / 54402, 335 ins, 347 del, 2340 sub ] exp/tri7b_DFSMN_S/decode_tgsmall_dev_clean/wer_11_0.0
+
+%WER 4.61 [ 2423 / 52576, 313 ins, 288 del, 1822 sub ] exp/tri7b_DFSMN_S/decode_fglarge_test_clean/wer_12_1.0
+%WER 4.69 [ 2468 / 52576, 325 ins, 282 del, 1861 sub ] exp/tri7b_DFSMN_S/decode_tglarge_test_clean/wer_13_0.5
+%WER 5.69 [ 2992 / 52576, 370 ins, 344 del, 2278 sub ] exp/tri7b_DFSMN_S/decode_tgmed_test_clean/wer_11_0.5
+%WER 6.28 [ 3301 / 52576, 366 ins, 428 del, 2507 sub ] exp/tri7b_DFSMN_S/decode_tgsmall_test_clean/wer_12_0.5
+
+%WER 11.71 [ 5968 / 50948, 719 ins, 704 del, 4545 sub ] exp/tri7b_DFSMN_S/decode_fglarge_dev_other/wer_15_0.0
+%WER 12.19 [ 6209 / 50948, 700 ins, 866 del, 4643 sub ] exp/tri7b_DFSMN_S/decode_tglarge_dev_other/wer_17_0.0
+%WER 14.25 [ 7260 / 50948, 755 ins, 1011 del, 5494 sub ] exp/tri7b_DFSMN_S/decode_tgmed_dev_other/wer_15_0.0
+%WER 15.35 [ 7823 / 50948, 741 ins, 1165 del, 5917 sub ] exp/tri7b_DFSMN_S/decode_tgsmall_dev_other/wer_15_0.0
+
+%WER 12.01 [ 6289 / 52343, 649 ins, 930 del, 4710 sub ] exp/tri7b_DFSMN_S/decode_fglarge_test_other/wer_16_0.0
+%WER 12.45 [ 6519 / 52343, 688 ins, 929 del, 4902 sub ] exp/tri7b_DFSMN_S/decode_tglarge_test_other/wer_15_0.0
+%WER 14.56 [ 7622 / 52343, 715 ins, 1191 del, 5716 sub ] exp/tri7b_DFSMN_S/decode_tgmed_test_other/wer_15_0.0
+%WER 15.68 [ 8208 / 52343, 743 ins, 1321 del, 6144 sub ] exp/tri7b_DFSMN_S/decode_tgsmall_test_other/wer_15_0.0
+
+# Results with nnet DFMSN_S + CE + SMBR
+# local/nnet/run_fsmn_ivector.sh DFSMN_S
+# Training on the "cleaned" data
+%WER 3.77 [ 2053 / 54402, 233 ins, 274 del, 1546 sub ] exp/tri7b_DFSMN_S_smbr/decode_fglarge_dev_clean/wer_27_0.5
+%WER 3.86 [ 2102 / 54402, 231 ins, 264 del, 1607 sub ] exp/tri7b_DFSMN_S_smbr/decode_tglarge_dev_clean/wer_26_0.5
+%WER 4.77 [ 2597 / 54402, 230 ins, 366 del, 2001 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgmed_dev_clean/wer_29_0.5
+%WER 5.21 [ 2836 / 54402, 290 ins, 329 del, 2217 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgsmall_dev_clean/wer_26_0.0
+
+%WER 4.26 [ 2239 / 52576, 250 ins, 313 del, 1676 sub ] exp/tri7b_DFSMN_S_smbr/decode_fglarge_test_clean/wer_27_1.0
+%WER 4.34 [ 2282 / 52576, 265 ins, 306 del, 1711 sub ] exp/tri7b_DFSMN_S_smbr/decode_tglarge_test_clean/wer_29_0.5
+%WER 5.22 [ 2746 / 52576, 319 ins, 315 del, 2112 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgmed_test_clean/wer_28_0.0
+%WER 5.81 [ 3055 / 52576, 357 ins, 329 del, 2369 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgsmall_test_clean/wer_25_0.0
+
+%WER 11.77 [ 5996 / 50948, 734 ins, 767 del, 4495 sub ] exp/tri7b_DFSMN_S_smbr/decode_fglarge_dev_other/wer_30_0.0
+%WER 12.09 [ 6158 / 50948, 644 ins, 926 del, 4588 sub ] exp/tri7b_DFSMN_S_smbr/decode_tglarge_dev_other/wer_30_0.5
+%WER 13.92 [ 7090 / 50948, 763 ins, 1018 del, 5309 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgmed_dev_other/wer_30_0.0
+%WER 14.85 [ 7564 / 50948, 749 ins, 1108 del, 5707 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgsmall_dev_other/wer_30_0.0
+
+%WER 11.65 [ 6099 / 52343, 595 ins, 1001 del, 4503 sub ] exp/tri7b_DFSMN_S_smbr/decode_fglarge_test_other/wer_30_0.5
+%WER 12.09 [ 6329 / 52343, 686 ins, 907 del, 4736 sub ] exp/tri7b_DFSMN_S_smbr/decode_tglarge_test_other/wer_30_0.0
+%WER 14.17 [ 7418 / 52343, 729 ins, 1115 del, 5574 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgmed_test_other/wer_30_0.0
+%WER 15.16 [ 7933 / 52343, 759 ins, 1228 del, 5946 sub ] exp/tri7b_DFSMN_S_smbr/decode_tgsmall_test_other/wer_30_0.0
+
+# Results with nnet DFMSN_M + CE
+# local/nnet/run_fsmn_ivector.sh DFSMN_M
+# Training on the "cleaned" data
+%WER 4.04 [ 2200 / 54402, 254 ins, 255 del, 1691 sub ] exp/tri7b_DFSMN_M/decode_fglarge_dev_clean/wer_12_1.0
+%WER 4.15 [ 2257 / 54402, 266 ins, 247 del, 1744 sub ] exp/tri7b_DFSMN_M/decode_tglarge_dev_clean/wer_13_0.5
+%WER 5.01 [ 2727 / 54402, 304 ins, 308 del, 2115 sub ] exp/tri7b_DFSMN_M/decode_tgmed_dev_clean/wer_12_0.5
+%WER 5.54 [ 3014 / 54402, 356 ins, 306 del, 2352 sub ] exp/tri7b_DFSMN_M/decode_tgsmall_dev_clean/wer_11_0.0
+
+%WER 4.50 [ 2367 / 52576, 328 ins, 263 del, 1776 sub ] exp/tri7b_DFSMN_M/decode_fglarge_test_clean/wer_13_0.5
+%WER 4.63 [ 2436 / 52576, 328 ins, 279 del, 1829 sub ] exp/tri7b_DFSMN_M/decode_tglarge_test_clean/wer_12_0.5
+%WER 5.50 [ 2894 / 52576, 331 ins, 373 del, 2190 sub ] exp/tri7b_DFSMN_M/decode_tgmed_test_clean/wer_13_0.5
+%WER 5.94 [ 3124 / 52576, 381 ins, 368 del, 2375 sub ] exp/tri7b_DFSMN_M/decode_tgsmall_test_clean/wer_13_0.0
+
+%WER 11.88 [ 6055 / 50948, 650 ins, 891 del, 4514 sub ] exp/tri7b_DFSMN_M/decode_fglarge_dev_other/wer_17_0.5
+%WER 12.24 [ 6236 / 50948, 746 ins, 811 del, 4679 sub ] exp/tri7b_DFSMN_M/decode_tglarge_dev_other/wer_17_0.0
+%WER 14.18 [ 7223 / 50948, 728 ins, 1056 del, 5439 sub ] exp/tri7b_DFSMN_M/decode_tgmed_dev_other/wer_17_0.0
+%WER 15.17 [ 7731 / 50948, 758 ins, 1139 del, 5834 sub ] exp/tri7b_DFSMN_M/decode_tgsmall_dev_other/wer_16_0.0
+
+%WER 12.23 [ 6404 / 52343, 716 ins, 908 del, 4780 sub ] exp/tri7b_DFSMN_M/decode_fglarge_test_other/wer_18_0.0
+%WER 12.61 [ 6598 / 52343, 736 ins, 890 del, 4972 sub ] exp/tri7b_DFSMN_M/decode_tglarge_test_other/wer_16_0.0
+%WER 14.55 [ 7614 / 52343, 710 ins, 1195 del, 5709 sub ] exp/tri7b_DFSMN_M/decode_tgmed_test_other/wer_17_0.0
+%WER 15.51 [ 8119 / 52343, 736 ins, 1272 del, 6111 sub ] exp/tri7b_DFSMN_M/decode_tgsmall_test_other/wer_16_0.0
+
+# Results with nnet DFMSN_L + CE
+# local/nnet/run_fsmn_ivector.sh DFSMN_L
+# Training on the "cleaned" data
+%WER 3.93 [ 2136 / 54402, 287 ins, 210 del, 1639 sub ] exp/tri7b_DFSMN_L/decode_fglarge_dev_clean/wer_12_0.5
+%WER 3.99 [ 2170 / 54402, 279 ins, 225 del, 1666 sub ] exp/tri7b_DFSMN_L/decode_tglarge_dev_clean/wer_12_0.5
+%WER 4.78 [ 2598 / 54402, 317 ins, 272 del, 2009 sub ] exp/tri7b_DFSMN_L/decode_tgmed_dev_clean/wer_12_0.0
+%WER 5.20 [ 2829 / 54402, 320 ins, 303 del, 2206 sub ] exp/tri7b_DFSMN_L/decode_tgsmall_dev_clean/wer_12_0.0
+
+%WER 4.36 [ 2294 / 52576, 285 ins, 267 del, 1742 sub ] exp/tri7b_DFSMN_L/decode_fglarge_test_clean/wer_14_0.5
+%WER 4.45 [ 2342 / 52576, 295 ins, 256 del, 1791 sub ] exp/tri7b_DFSMN_L/decode_tglarge_test_clean/wer_12_0.5
+%WER 5.29 [ 2782 / 52576, 320 ins, 326 del, 2136 sub ] exp/tri7b_DFSMN_L/decode_tgmed_test_clean/wer_12_0.5
+%WER 5.68 [ 2988 / 52576, 372 ins, 317 del, 2299 sub ] exp/tri7b_DFSMN_L/decode_tgsmall_test_clean/wer_11_0.0
+
+%WER 11.71 [ 5964 / 50948, 584 ins, 881 del, 4499 sub ] exp/tri7b_DFSMN_L/decode_fglarge_dev_other/wer_17_0.5
+%WER 12.13 [ 6179 / 50948, 668 ins, 822 del, 4689 sub ] exp/tri7b_DFSMN_L/decode_tglarge_dev_other/wer_17_0.0
+%WER 13.86 [ 7063 / 50948, 694 ins, 1051 del, 5318 sub ] exp/tri7b_DFSMN_L/decode_tgmed_dev_other/wer_17_0.0
+%WER 14.82 [ 7548 / 50948, 718 ins, 1075 del, 5755 sub ] exp/tri7b_DFSMN_L/decode_tgsmall_dev_other/wer_15_0.0
+
+%WER 12.00 [ 6281 / 52343, 724 ins, 813 del, 4744 sub ] exp/tri7b_DFSMN_L/decode_fglarge_test_other/wer_16_0.0
+%WER 12.43 [ 6505 / 52343, 719 ins, 858 del, 4928 sub ] exp/tri7b_DFSMN_L/decode_tglarge_test_other/wer_16_0.0
+%WER 13.99 [ 7323 / 52343, 688 ins, 1125 del, 5510 sub ] exp/tri7b_DFSMN_L/decode_tgmed_test_other/wer_17_0.0
+%WER 14.90 [ 7797 / 52343, 754 ins, 1106 del, 5937 sub ] exp/tri7b_DFSMN_L/decode_tgsmall_test_other/wer_15_0.0
+
+# Results with nnet DFMSN_L + CE + SMBR
+# Training on speed-perturbed and volumn-perturbed "cleaned" data
+%WER 3.60 [ 1959 / 54402, 243 ins, 171 del, 1545 sub ] exp/DFSMN_L_sp_vp_smbr/decode_fglarge_dev_clean/wer_26_0.0
+%WER 3.69 [ 2010 / 54402, 194 ins, 226 del, 1590 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tglarge_dev_clean/wer_25_1.0
+%WER 4.40 [ 2394 / 54402, 213 ins, 278 del, 1903 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgmed_dev_clean/wer_25_0.5
+%WER 4.79 [ 2608 / 54402, 261 ins, 267 del, 2080 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgsmall_dev_clean/wer_19_0.5
+
+%WER 3.96 [ 2083 / 52576, 280 ins, 177 del, 1626 sub ] exp/DFSMN_L_sp_vp_smbr/decode_fglarge_test_clean/wer_23_0.5
+%WER 4.09 [ 2152 / 52576, 243 ins, 238 del, 1671 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tglarge_test_clean/wer_25_1.0
+%WER 4.73 [ 2486 / 52576, 276 ins, 264 del, 1946 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgmed_test_clean/wer_25_0.5
+%WER 5.10 [ 2682 / 52576, 304 ins, 279 del, 2099 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgsmall_test_clean/wer_21_0.5
+
+%WER 10.21 [ 5203 / 50948, 531 ins, 650 del, 4022 sub ] exp/DFSMN_L_sp_vp_smbr/decode_fglarge_dev_other/wer_30_0.5
+%WER 10.77 [ 5485 / 50948, 554 ins, 697 del, 4234 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tglarge_dev_other/wer_29_0.5
+%WER 12.39 [ 6314 / 50948, 534 ins, 891 del, 4889 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgmed_dev_other/wer_29_0.5
+%WER 13.01 [ 6630 / 50948, 608 ins, 885 del, 5137 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgsmall_dev_other/wer_30_0.0
+
+%WER 10.39 [ 5439 / 52343, 560 ins, 637 del, 4242 sub ] exp/DFSMN_L_sp_vp_smbr/decode_fglarge_test_other/wer_30_0.5
+%WER 10.89 [ 5702 / 52343, 580 ins, 696 del, 4426 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tglarge_test_other/wer_30_0.5
+%WER 12.49 [ 6540 / 52343, 669 ins, 782 del, 5089 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgmed_test_other/wer_30_0.0
+%WER 13.29 [ 6958 / 52343, 737 ins, 799 del, 5422 sub ] exp/DFSMN_L_sp_vp_smbr/decode_tgsmall_test_other/wer_26_0.0
diff --git a/egs/librispeech/s5/conf/fbank.conf b/egs/librispeech/s5/conf/fbank.conf
new file mode 100644
index 0000000..25bcdd1
--- /dev/null
+++ b/egs/librispeech/s5/conf/fbank.conf
@@ -0,0 +1,6 @@
+--htk-compat=false
+--window-type=hamming # disable Dans window, use the standard
+--use-energy=false # only fbank outputs
+--dither=1
+--num-mel-bins=80 # 8 filters/octave, 40 filters/16Khz as used by IBM
+--sample-frequency=16000
diff --git a/egs/librispeech/s5/local/nnet/DFSMN_L.proto b/egs/librispeech/s5/local/nnet/DFSMN_L.proto
new file mode 100644
index 0000000..738b486
--- /dev/null
+++ b/egs/librispeech/s5/local/nnet/DFSMN_L.proto
@@ -0,0 +1,23 @@
+<NnetProto>
+<AffineTransform> <InputDim> 1020 <OutputDim> 2048 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<LinearTransform> <InputDim> 2048 <OutputDim> 512 <Xavier> 1
+<Fsmn> <InputDim> 512 <OutputDim> 512 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<AffineTransform> <InputDim> 512 <OutputDim> 2048 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<AffineTransform> <InputDim> 2048 <OutputDim> 2048 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<LinearTransform> <InputDim> 2048 <OutputDim> 512 <Xavier> 1
+<AffineTransform> <InputDim> 512 <OutputDim> 5777 <Xavier> 1
+<Softmax> <InputDim> 5777 <OutputDim> 5777
+</NnetProto>
+
diff --git a/egs/librispeech/s5/local/nnet/DFSMN_M.proto b/egs/librispeech/s5/local/nnet/DFSMN_M.proto
new file mode 100644
index 0000000..ea3ed45
--- /dev/null
+++ b/egs/librispeech/s5/local/nnet/DFSMN_M.proto
@@ -0,0 +1,19 @@
+<NnetProto>
+<AffineTransform> <InputDim> 1020 <OutputDim> 2048 <MaxNorm> 0.000000 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<LinearTransform> <InputDim> 2048 <OutputDim> 512 <ParamStddev> 0.010000 <Xavier> 1
+<Fsmn> <InputDim> 512 <OutputDim> 512 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 512 <OutputDim> 512 <HidSize> 2048 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<AffineTransform> <InputDim> 512 <OutputDim> 2048 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<AffineTransform> <InputDim> 2048 <OutputDim> 2048 <Xavier> 1
+<ParametricRelu> <InputDim> 2048 <OutputDim> 2048
+<LinearTransform> <InputDim> 2048 <OutputDim> 512 <Xavier> 1
+<AffineTransform> <InputDim> 512 <OutputDim> 5777 <Xavier> 1
+<Softmax> <InputDim> 5777 <OutputDim> 5777
+</NnetProto>
+
diff --git a/egs/librispeech/s5/local/nnet/DFSMN_S.proto b/egs/librispeech/s5/local/nnet/DFSMN_S.proto
new file mode 100644
index 0000000..cd2d026
--- /dev/null
+++ b/egs/librispeech/s5/local/nnet/DFSMN_S.proto
@@ -0,0 +1,19 @@
+<NnetProto>
+<AffineTransform> <InputDim> 1020 <OutputDim> 1024 <MaxNorm> 0.000000 <Xavier> 1
+<ParametricRelu> <InputDim> 1024 <OutputDim> 1024
+<LinearTransform> <InputDim> 1024 <OutputDim> 384 <ParamStddev> 0.010000 <Xavier> 1
+<Fsmn> <InputDim> 384 <OutputDim> 384 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 384 <OutputDim> 384 <HidSize> 1024 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 384 <OutputDim> 384 <HidSize> 1024 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 384 <OutputDim> 384 <HidSize> 1024 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 384 <OutputDim> 384 <HidSize> 1024 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<DeepFsmn> <InputDim> 384 <OutputDim> 384 <HidSize> 1024 <LOrder> 20 <ROrder> 20 <LStride> 2 <RStride> 2
+<AffineTransform> <InputDim> 384 <OutputDim> 1024 <Xavier> 1
+<ParametricRelu> <InputDim> 1024 <OutputDim> 1024
+<AffineTransform> <InputDim> 1024 <OutputDim> 1024 <Xavier> 1
+<ParametricRelu> <InputDim> 1024 <OutputDim> 1024
+<LinearTransform> <InputDim> 1024 <OutputDim> 384 <Xavier> 1
+<AffineTransform> <InputDim> 384 <OutputDim> 5777 <Xavier> 1
+<Softmax> <InputDim> 5777 <OutputDim> 5777
+</NnetProto>
+
diff --git a/egs/librispeech/s5/local/nnet/run_fsmn_ivector.sh b/egs/librispeech/s5/local/nnet/run_fsmn_ivector.sh
new file mode 100644
index 0000000..dcebb00
--- /dev/null
+++ b/egs/librispeech/s5/local/nnet/run_fsmn_ivector.sh
@@ -0,0 +1,142 @@
+. ./path.sh
+. ./cmd.sh
+
+. utils/parse_options.sh || exit 1;
+
+set -e
+set -u
+set -o pipefail
+#########################
+
+dnn_model=$1
+
+stage=0
+
+if [ $stage -le 0 ]; then
+ min_seg_len=1.55
+ train_set=train_960_cleaned
+ gmm=tri6b_cleaned
+ nnet3_affix=_cleaned
+ local/nnet3/run_ivector_common.sh --stage $stage \
+ --min-seg-len $min_seg_len \
+ --train-set $train_set \
+ --gmm $gmm \
+ --num-threads-ubm 6 --num-processes 3 \
+ --nnet3-affix "$nnet3_affix" || exit 1;
+then
+
+##Make fbank features
+if [ $stage -le 1 ]; then
+ mkdir -p data_fbank
+
+ for x in train_960_cleaned test_other test_clean dev_other dev_clean; do
+ fbankdir=fbank/$x
+
+ cp -r data/$x data_fbank/$x
+ steps/make_fbank.sh --nj 30 --cmd "$train_cmd" --fbank-config conf/fbank.conf \
+ data_fbank/$x exp/make_fbank/$x $fbankdir
+ steps/compute_cmvn_stats.sh data_fbank/$x exp/make_fbank/$x $fbankdir
+done
+fi
+###############
+if [ $stage -le 2 ]; then
+
+ steps/align_fmllr.sh --nj 30 --cmd "$train_cmd" \
+ data/train_960_cleaned data/lang exp/tri6b_cleaned exp/tri6b_cleaned_ali_train_960_cleaned
+ steps/align_fmllr.sh --nj 10 --cmd "$train_cmd" \
+ data/dev_clean data/lang exp/tri6b_cleaned exp/tri6b_cleaned_ali_dev_clean
+ steps/align_fmllr.sh --nj 10 --cmd "$train_cmd" \
+ data/dev_other data/lang exp/tri6b_cleaned exp/tri6b_cleaned_ali_dev_other
+fi
+#####CE-training
+lrate=0.00001
+dir=exp/tri7b_${dnn_model}
+data_fbk=data_fbank
+if [ $stage -le 3 ]; then
+ proto=proto/${dnn_model}.proto
+
+ cat exp/nnet3_cleaned/ivectors_train_960_cleaned_hires/ivector_online.scp exp/nnet3_cleaned/ivectors_dev_clean_hires/ivector_online.scp \
+ exp/nnet3_cleaned/ivectors_dev_other_hires/ivector_online.scp > exp/nnet3_cleaned/ivectors_train_960_dev_hires/ivector_online.scp
+
+ $cuda_cmd $dir/_train_nnet.log \
+ steps/nnet/train_faster.sh --learn-rate $lrate --nnet-proto $proto \
+ --start_half_lr 5 --momentum 0.9 \
+ --train-tool "nnet-train-fsmn-streams" \
+ --feat-type plain --splice 1 \
+ --cmvn-opts "--norm-means=true --norm-vars=false" --delta_opts "--delta-order=2" \
+ --train-tool-opts "--minibatch-size=4096" \
+ --ivector scp:exp/nnet3_cleaned/ivectors_train_960_dev_hires/ivector_online.scp \
+ --ivector-append-tool "append-ivector-to-feats --online-ivector-period=10" \
+ $data_fbk/train_960_cleaned $data_fbk/dev_clean data/lang exp/tri6b_cleaned_ali_train_960_cleaned exp/tri6b_cleaned_ali_dev_clean $dir
+fi
+####Decode
+acwt=0.08
+if [ $stage -le 4 ]; then
+ gmm=exp/tri6b_cleaned
+ dataset="test_clean dev_clean test_other dev_other"
+ for set in $dataset
+ do
+ steps/nnet/decode.sh --nj 16 --cmd "$decode_cmd" \
+ --acwt $acwt \
+ $gmm/graph_tgsmall \
+ $data_fbk/$set $dir/decode_tgsmall_${set}
+
+ steps/lmrescore.sh --cmd "$decode_cmd" data/lang_test_{tgsmall,tgmed} \
+ $data_fbk/$set $dir/decode_{tgsmall,tgmed}_${set}
+
+ steps/lmrescore_const_arpa.sh \
+ --cmd "$decode_cmd" data/lang_test_{tgsmall,tglarge} \
+ $data_fbk/$set $dir/decode_{tgsmall,tglarge}_${set}
+
+ steps/lmrescore_const_arpa.sh \
+ --cmd "$decode_cmd" data/lang_test_{tgsmall,fglarge} \
+ $data_fbk/$set $dir/decode_{tgsmall,fglarge}_${set}
+ done
+ for x in $dir/decode_*;
+ do
+ grep WER $x/wer_* | utils/best_wer.sh
+ done
+fi
+
+nj=32
+if [ $stage -le 5 ]; then
+ steps/nnet/align.sh --nj $nj --cmd "$train_cmd" $data_fbk/train_960_cleaned data/lang $dir ${dir}_ali
+ steps/nnet/make_denlats.sh --nj $nj --cmd "$decode_cmd" --acwt $acwt \
+ $data_fbk/train_960_cleaned data/lang $dir ${dir}_denlats
+fi
+
+####do smbr
+if [ $stage -le 5 ]; then
+ steps/nnet/train_mpe.sh --cmd "$cuda_cmd" --num-iters 2 --learn-rate 0.0000002 --acwt $acwt --do-smbr true \
+ $data_fbk/train_960_cleaned data/lang $dir ${dir}_ali ${dir}_denlats ${dir}_smbr
+fi
+###decode
+dir=${dir}_smbr
+acwt=0.03
+if [ $stage -le 6 ]; then
+ gmm=exp/tri6b_cleaned
+ dataset="test_clean dev_clean test_other dev_other"
+ for set in $dataset
+ do
+ steps/nnet/decode.sh --nj 16 --cmd "$decode_cmd" \
+ --acwt $acwt \
+ $gmm/graph_tgsmall \
+ $data_fbk/$set $dir/decode_tgsmall_${set}
+
+ steps/lmrescore.sh --cmd "$decode_cmd" data/lang_test_{tgsmall,tgmed} \
+ $data_fbk/$set $dir/decode_{tgsmall,tgmed}_${set}
+
+ steps/lmrescore_const_arpa.sh \
+ --cmd "$decode_cmd" data/lang_test_{tgsmall,tglarge} \
+ $data_fbk/$set $dir/decode_{tgsmall,tglarge}_${set}
+
+ steps/lmrescore_const_arpa.sh \
+ --cmd "$decode_cmd" data/lang_test_{tgsmall,fglarge} \
+ $data_fbk/$set $dir/decode_{tgsmall,fglarge}_${set}
+ done
+ for x in $dir/decode_*;
+ do
+ grep WER $x/wer_* | utils/best_wer.sh
+ done
+fi
+
diff --git a/egs/librispeech/s5/run.sh b/egs/librispeech/s5/run.sh
index 1b12f51..d2b8b4b 100755
--- a/egs/librispeech/s5/run.sh
+++ b/egs/librispeech/s5/run.sh
@@ -353,7 +353,7 @@ local/run_cleanup_segmentation.sh
# train nnet3 tdnn models on the entire data with data-cleaning (xent and chain)
-local/chain/run_tdnn.sh # set "--stage 11" if you have already run local/nnet3/run_tdnn.sh
+#local/chain/run_tdnn.sh # set "--stage 11" if you have already run local/nnet3/run_tdnn.sh
# The nnet3 TDNN recipe:
# local/nnet3/run_tdnn.sh # set "--stage 11" if you have already run local/chain/run_tdnn.sh
@@ -372,5 +372,15 @@ local/chain/run_tdnn.sh # set "--stage 11" if you have already run local/nnet3/r
# ## to train but slightly worse.
# # local/online/run_nnet2.sh
+
+# ## Traing FSMN models on the cleaned-up data
+# ## Three configurations of DFSMN with different model size: DFSMN_S, DFSMN_M, DFSMN_L
+local/nnet/run_fsmn_ivector.sh DFSMN_S
+# local/nnet/run_fsmn_ivector.sh DFSMN_M
+# local/nnet/run_fsmn_ivector.sh DFSMN_L
+
+# Wait for decodings in the background
+
+
# Wait for decodings in the background
wait
diff --git a/egs/wsj/s5/steps/nnet/train_faster.sh b/egs/wsj/s5/steps/nnet/train_faster.sh
new file mode 100755
index 0000000..b751e69
--- /dev/null
+++ b/egs/wsj/s5/steps/nnet/train_faster.sh
@@ -0,0 +1,481 @@
+#!/bin/bash
+
+# Copyright 2012-2017 Brno University of Technology (author: Karel Vesely)
+# Apache 2.0
+
+# Begin configuration.
+
+config= # config, also forwarded to 'train_scheduler.sh',
+
+# topology, initialization,
+network_type=dnn # select type of neural network (dnn,cnn1d,cnn2d,lstm),
+hid_layers=4 # nr. of hidden layers (before sotfmax or bottleneck),
+hid_dim=1024 # number of neurons per layer,
+bn_dim= # (optional) adds bottleneck and one more hidden layer to the NN,
+dbn= # (optional) prepend layers to the initialized NN,
+
+proto_opts= # adds options to 'make_nnet_proto.py',
+cnn_proto_opts= # adds options to 'make_cnn_proto.py',
+
+nnet_init= # (optional) use this pre-initialized NN,
+nnet_proto= # (optional) use this NN prototype for initialization,
+
+# feature processing,
+splice=5 # (default) splice features both-ways along time axis,
+cmvn_opts= # (optional) adds 'apply-cmvn' to input feature pipeline, see opts,
+delta_opts= # (optional) adds 'add-deltas' to input feature pipeline, see opts,
+ivector= # (optional) adds 'append-vector-to-feats', the option is rx-filename for the 2nd stream,
+ivector_append_tool=append-vector-to-feats # (optional) the tool for appending ivectors,
+
+feat_type=plain
+traps_dct_basis=11 # (feat_type=traps) nr. of DCT basis, 11 is good with splice=10,
+transf= # (feat_type=transf) import this linear tranform,
+splice_after_transf=5 # (feat_type=transf) splice after the linear transform,
+
+feature_transform_proto= # (optional) use this prototype for 'feature_transform',
+feature_transform= # (optional) directly use this 'feature_transform',
+pytel_transform= # (BUT) use external python transform,
+
+# labels,
+labels= # (optional) specify non-default training targets,
+ # (targets need to be in posterior format, see 'ali-to-post', 'feat-to-post'),
+num_tgt= # (optional) specifiy number of NN outputs, to be used with 'labels=',
+
+# training scheduler,
+learn_rate=0.008 # initial learning rate,
+momentum=0
+start_half_lr=5 # start to anneal the learning rate
+seed=777 # random seed
+scheduler_opts= # options, passed to the training scheduler,
+train_tool= # optionally change the training tool,
+train_tool_opts= # options for the training tool,
+frame_weights= # per-frame weights for gradient weighting,
+utt_weights= # per-utterance weights (scalar for --frame-weights),
+
+# data processing, misc.
+copy_feats=false # resave the train/cv features into /tmp (disabled by default),
+copy_feats_tmproot=/tmp/kaldi.XXXX # sets tmproot for 'copy-feats',
+copy_feats_compress=true # compress feats while resaving
+feats_std=1.0
+
+split_feats= # split the training data into N portions, one portion will be one 'epoch',
+ # (empty = no splitting)
+
+seed=777 # seed value used for data-shuffling, nn-initialization, and training,
+skip_cuda_check=false
+skip_phoneset_check=false
+
+# End configuration.
+
+echo "$0 $@" # Print the command line for logging
+
+[ -f path.sh ] && . ./path.sh;
+. parse_options.sh || exit 1;
+
+set -euo pipefail
+
+if [ $# != 6 ]; then
+ echo "Usage: $0 <data-train> <data-dev> <lang-dir> <ali-train> <ali-dev> <exp-dir>"
+ echo " e.g.: $0 data/train data/cv data/lang exp/mono_ali_train exp/mono_ali_cv exp/mono_nnet"
+ echo ""
+ echo " Training data : <data-train>,<ali-train> (for optimizing cross-entropy)"
+ echo " Held-out data : <data-dev>,<ali-dev> (for learn-rate scheduling, model selection)"
+ echo " note.: <ali-train>,<ali-dev> can point to same directory, or 2 separate directories."
+ echo ""
+ echo "main options (for others, see top of script file)"
+ echo " --config <config-file> # config containing options"
+ echo ""
+ echo " --network-type (dnn,cnn1d,cnn2d,lstm) # type of neural network"
+ echo " --nnet-proto <file> # use this NN prototype"
+ echo " --feature-transform <file> # re-use this input feature transform"
+ echo ""
+ echo " --feat-type (plain|traps|transf) # type of input features"
+ echo " --cmvn-opts <string> # add 'apply-cmvn' to input feature pipeline"
+ echo " --delta-opts <string> # add 'add-deltas' to input feature pipeline"
+ echo " --splice <N> # splice +/-N frames of input features"
+ echo
+ echo " --learn-rate <float> # initial leaning-rate"
+ echo " --copy-feats <bool> # copy features to /tmp, lowers storage stress"
+ echo ""
+ exit 1;
+fi
+
+data=$1
+data_cv=$2
+lang=$3
+alidir=$4
+alidir_cv=$5
+dir=$6
+
+# Using alidir for supervision (default)
+if [ -z "$labels" ]; then
+ silphonelist=`cat $lang/phones/silence.csl`
+ for f in $alidir/final.mdl $alidir/ali.1.gz $alidir_cv/ali.1.gz; do
+ [ ! -f $f ] && echo "$0: no such file $f" && exit 1;
+ done
+fi
+
+for f in $data/feats.scp $data_cv/feats.scp; do
+ [ ! -f $f ] && echo "$0: no such file $f" && exit 1;
+done
+
+echo
+echo "# INFO"
+echo "$0 : Training Neural Network"
+printf "\t dir : $dir \n"
+printf "\t Train-set : $data $(cat $data/feats.scp | wc -l), $alidir \n"
+printf "\t CV-set : $data_cv $(cat $data_cv/feats.scp | wc -l) $alidir_cv \n"
+echo
+
+mkdir -p $dir/{log,nnet}
+
+if ! $skip_phoneset_check; then
+ utils/lang/check_phones_compatible.sh $lang/phones.txt $alidir/phones.txt
+ utils/lang/check_phones_compatible.sh $lang/phones.txt $alidir_cv/phones.txt
+ cp $lang/phones.txt $dir
+fi
+
+# skip when already trained,
+if [ -e $dir/final.nnet ]; then
+ echo "SKIPPING TRAINING... ($0)"
+ echo "nnet already trained : $dir/final.nnet ($(readlink $dir/final.nnet))"
+ exit 0
+fi
+
+# check if CUDA compiled in and GPU is available,
+if ! $skip_cuda_check; then cuda-gpu-available || exit 1; fi
+
+###### PREPARE ALIGNMENTS ######
+echo
+echo "# PREPARING ALIGNMENTS"
+if [ ! -z "$labels" ]; then
+ echo "Using targets '$labels' (by force)"
+ labels_tr="$labels"
+ labels_cv="$labels"
+else
+ echo "Using PDF targets from dirs '$alidir' '$alidir_cv'"
+ # training targets in posterior format,
+ labels_tr="ark:ali-to-pdf $alidir/final.mdl \"ark:gunzip -c $alidir/ali.*.gz |\" ark:- | ali-to-post ark:- ark:- |"
+ labels_cv="ark:ali-to-pdf $alidir/final.mdl \"ark:gunzip -c $alidir_cv/ali.*.gz |\" ark:- | ali-to-post ark:- ark:- |"
+ # training targets for analyze-counts,
+ labels_tr_pdf="ark:ali-to-pdf $alidir/final.mdl \"ark:gunzip -c $alidir/ali.*.gz |\" ark:- |"
+ labels_tr_phn="ark:ali-to-phones --per-frame=true $alidir/final.mdl \"ark:gunzip -c $alidir/ali.*.gz |\" ark:- |"
+
+ # get pdf-counts, used later for decoding/aligning,
+ num_pdf=$(hmm-info $alidir/final.mdl | awk '/pdfs/{print $4}')
+ analyze-counts --verbose=1 --binary=false --counts-dim=$num_pdf \
+ ${frame_weights:+ "--frame-weights=$frame_weights"} \
+ ${utt_weights:+ "--utt-weights=$utt_weights"} \
+ "$labels_tr_pdf" $dir/ali_train_pdf.counts 2>$dir/log/analyze_counts_pdf.log
+ # copy the old transition model, will be needed by decoder,
+ copy-transition-model --binary=false $alidir/final.mdl $dir/final.mdl
+ # copy the tree
+ cp $alidir/tree $dir/tree
+
+ # make phone counts for analysis,
+ [ -e $lang/phones.txt ] && analyze-counts --verbose=1 --symbol-table=$lang/phones.txt --counts-dim=$num_pdf \
+ ${frame_weights:+ "--frame-weights=$frame_weights"} \
+ ${utt_weights:+ "--utt-weights=$utt_weights"} \
+ "$labels_tr_phn" /dev/null 2>$dir/log/analyze_counts_phones.log
+fi
+
+###### PREPARE FEATURES ######
+echo
+echo "# PREPARING FEATURES"
+if [ "$copy_feats" == "true" ]; then
+ echo "# re-saving features to local disk,"
+ tmpdir=$(mktemp -d $copy_feats_tmproot)
+ copy-feats --compress=$copy_feats_compress scp:$data/feats.scp ark,scp:$tmpdir/train.ark,$dir/train_sorted.scp
+ copy-feats --compress=$copy_feats_compress scp:$data_cv/feats.scp ark,scp:$tmpdir/cv.ark,$dir/cv.scp
+ trap "echo '# Removing features tmpdir $tmpdir @ $(hostname)'; ls $tmpdir; rm -r $tmpdir" EXIT
+else
+ # or copy the list,
+ cp $data/feats.scp $dir/train_sorted.scp
+ cp $data_cv/feats.scp $dir/cv.scp
+fi
+# shuffle the list,
+utils/shuffle_list.pl --srand ${seed:-777} <$dir/train_sorted.scp >$dir/train.scp
+
+# create a 10k utt subset for global cmvn estimates,
+head -n 10000 $dir/train.scp > $dir/train.scp.10k
+head -n 1000 $dir/train.scp > $dir/train.scp.1k
+
+# split the list,
+if [ -n "$split_feats" ]; then
+ scps= # 1..split_feats,
+ for (( ii=1; ii<=$split_feats; ii++ )); do scps="$scps $dir/train.${ii}.scp"; done
+ utils/split_scp.pl $dir/train.scp $scps
+fi
+
+# for debugging, add lists with non-local features,
+utils/shuffle_list.pl --srand ${seed:-777} <$data/feats.scp >$dir/train.scp_non_local
+cp $data_cv/feats.scp $dir/cv.scp_non_local
+
+###### OPTIONALLY IMPORT FEATURE SETTINGS (from pre-training) ######
+ivector_dim= # no ivectors,
+if [ ! -z $feature_transform ]; then
+ D=$(dirname $feature_transform)
+ echo "# importing feature settings from dir '$D'"
+ [ -e $D/norm_vars ] && cmvn_opts="--norm-means=true --norm-vars=$(cat $D/norm_vars)" # Bwd-compatibility,
+ [ -e $D/cmvn_opts ] && cmvn_opts=$(cat $D/cmvn_opts)
+ [ -e $D/delta_order ] && delta_opts="--delta-order=$(cat $D/delta_order)" # Bwd-compatibility,
+ [ -e $D/delta_opts ] && delta_opts=$(cat $D/delta_opts)
+ [ -e $D/ivector_dim ] && ivector_dim=$(cat $D/ivector_dim)
+ [ -e $D/ivector_append_tool ] && ivector_append_tool=$(cat $D/ivector_append_tool)
+ echo "# cmvn_opts='$cmvn_opts' delta_opts='$delta_opts' ivector_dim='$ivector_dim'"
+fi
+
+###### PREPARE FEATURE PIPELINE ######
+# read the features,
+feats_tr="ark:copy-feats scp:$dir/train.scp ark:- |"
+feats_cv="ark:copy-feats scp:$dir/cv.scp ark:- |"
+
+# optionally add per-speaker CMVN,
+if [ ! -z "$cmvn_opts" ]; then
+ echo "# + 'apply-cmvn' with '$cmvn_opts' using statistics : $data/cmvn.scp, $data_cv/cmvn.scp"
+ [ ! -r $data/cmvn.scp ] && echo "Missing $data/cmvn.scp" && exit 1;
+ [ ! -r $data_cv/cmvn.scp ] && echo "Missing $data_cv/cmvn.scp" && exit 1;
+ feats_tr="$feats_tr apply-cmvn $cmvn_opts --utt2spk=ark:$data/utt2spk scp:$data/cmvn.scp ark:- ark:- |"
+ feats_cv="$feats_cv apply-cmvn $cmvn_opts --utt2spk=ark:$data_cv/utt2spk scp:$data_cv/cmvn.scp ark:- ark:- |"
+else
+ echo "# 'apply-cmvn' is not used,"
+fi
+
+# optionally add deltas,
+if [ ! -z "$delta_opts" ]; then
+ feats_tr="$feats_tr add-deltas $delta_opts ark:- ark:- |"
+ feats_cv="$feats_cv add-deltas $delta_opts ark:- ark:- |"
+ echo "# + 'add-deltas' with '$delta_opts'"
+fi
+
+# keep track of the config,
+[ ! -z "$cmvn_opts" ] && echo "$cmvn_opts" >$dir/cmvn_opts
+[ ! -z "$delta_opts" ] && echo "$delta_opts" >$dir/delta_opts
+#
+
+# optionally append python feature transform,
+if [ ! -z "$pytel_transform" ]; then
+ cp $pytel_transform $dir/pytel_transform.py
+ { echo; echo "### Comes from here: '$pytel_transform' ###"; } >> $dir/pytel_transform.py
+ pytel_transform=$dir/pytel_transform.py
+ feats_tr="$feats_tr /bin/env python $pytel_transform |"
+ feats_cv="$feats_cv /bin/env python $pytel_transform |"
+ echo "# + 'pytel-transform' from '$pytel_transform'"
+fi
+
+# temoprary pipeline with first 1k,
+feats_tr_1k="${feats_tr/train.scp/train.scp.1k}"
+
+if [ ! -z $ivector ]; then
+ echo
+ echo "# ADDING IVECTOR FEATURES"
+
+ echo "# getting dims,"
+ dim_raw=$(feat-to-dim "$feats_tr_1k" -)
+ dim_raw_and_ivec=$(feat-to-dim "$feats_tr_1k $ivector_append_tool ark:- '$ivector' ark:- |" -)
+ dim_ivec=$((dim_raw_and_ivec - dim_raw))
+ echo "# dims, feats-raw $dim_raw, ivectors $dim_ivec,"
+
+ echo $dim_ivec >$dir/ivector_dim # mark down the iVec dim!
+ echo $ivector_append_tool >$dir/ivector_append_tool
+
+ # pasting the iVecs to the feaures,
+ echo "# + ivector input '$ivector'"
+ feats_tr="$feats_tr $ivector_append_tool ark:- '$ivector' ark:- |"
+ feats_cv="$feats_cv $ivector_append_tool ark:- '$ivector' ark:- |"
+fi
+
+# temoprary pipeline with first 10k,
+feats_tr_10k="${feats_tr/train.scp/train.scp.10k}"
+
+# get feature dim,
+feat_dim=$(feat-to-dim "$feats_tr_10k" -)
+echo "# feature dim : $feat_dim (input of 'feature_transform')"
+
+
+# Now we start building 'feature_transform' which goes right in front of a NN.
+# The forwarding is computed on a GPU before the frame shuffling is applied.
+#
+# Same GPU is used both for 'feature_transform' and the NN training.
+# So it has to be done by a single process (we are using exclusive mode).
+# This also reduces the CPU-GPU uploads/downloads to minimum.
+
+if [ ! -z "$feature_transform" ]; then
+ echo "# importing 'feature_transform' from '$feature_transform'"
+ tmp=$dir/imported_$(basename $feature_transform)
+ cp $feature_transform $tmp; feature_transform=$tmp
+else
+ # Make default proto with splice,
+ if [ ! -z $feature_transform_proto ]; then
+ echo "# importing custom 'feature_transform_proto' from '$feature_transform_proto'"
+ else
+ echo "# + default 'feature_transform_proto' with splice +/-$splice frames,"
+ feature_transform_proto=$dir/splice${splice}.proto
+ echo "<Splice> <InputDim> $feat_dim <OutputDim> $(((2*splice+1)*feat_dim)) <BuildVector> -$splice:$splice </BuildVector>" >$feature_transform_proto
+ fi
+
+ # Initialize 'feature-transform' from a prototype,
+ feature_transform=$dir/tr_$(basename $feature_transform_proto .proto).nnet
+ nnet-initialize --binary=false $feature_transform_proto $feature_transform
+
+ # Choose further processing of spliced features
+ echo "# feature type : $feat_type"
+ case $feat_type in
+ plain)
+ ;;
+ traps)
+ #generate hamming+dct transform
+ feature_transform_old=$feature_transform
+ feature_transform=${feature_transform%.nnet}_hamm_dct${traps_dct_basis}.nnet
+ echo "# + Hamming DCT transform (t$((splice*2+1)),dct${traps_dct_basis}) into '$feature_transform'"
+ #prepare matrices with time-transposed hamming and dct
+ utils/nnet/gen_hamm_mat.py --fea-dim=$feat_dim --splice=$splice > $dir/hamm.mat
+ utils/nnet/gen_dct_mat.py --fea-dim=$feat_dim --splice=$splice --dct-basis=$traps_dct_basis > $dir/dct.mat
+ #put everything together
+ compose-transforms --binary=false $dir/dct.mat $dir/hamm.mat - | \
+ transf-to-nnet - - | \
+ nnet-concat --binary=false $feature_transform_old - $feature_transform
+ ;;
+ transf)
+ feature_transform_old=$feature_transform
+ feature_transform=${feature_transform%.nnet}_transf_splice${splice_after_transf}.nnet
+ [ -z $transf ] && transf=$alidir/final.mat
+ [ ! -f $transf ] && echo "Missing transf $transf" && exit 1
+ feat_dim=$(feat-to-dim "$feats_tr_10k nnet-forward 'nnet-concat $feature_transform_old \"transf-to-nnet $transf - |\" - |' ark:- ark:- |" -)
+ nnet-concat --binary=false $feature_transform_old \
+ "transf-to-nnet $transf - |" \
+ "utils/nnet/gen_splice.py --fea-dim=$feat_dim --splice=$splice_after_transf |" \
+ $feature_transform
+ ;;
+ *)
+ echo "Unknown feature type $feat_type"
+ exit 1;
+ ;;
+ esac
+
+ # keep track of feat_type,
+ echo $feat_type > $dir/feat_type
+
+ # Renormalize the MLP input to zero mean and unit variance,
+ feature_transform_old=$feature_transform
+ feature_transform=${feature_transform%.nnet}_cmvn-g.nnet
+ echo "# compute normalization stats from 10k sentences"
+ nnet-forward --print-args=true --use-gpu=yes $feature_transform_old \
+ "$feats_tr_10k" ark:- |\
+ compute-cmvn-stats ark:- $dir/cmvn-g.stats
+ echo "# + normalization of NN-input at '$feature_transform'"
+ nnet-concat --binary=false $feature_transform_old \
+ "cmvn-to-nnet --std-dev=$feats_std $dir/cmvn-g.stats -|" $feature_transform
+fi
+
+
+###### Show the final 'feature_transform' in the log,
+echo
+echo "### Showing the final 'feature_transform':"
+nnet-info $feature_transform
+echo "###"
+
+###### MAKE LINK TO THE FINAL feature_transform, so the other scripts will find it ######
+[ -f $dir/final.feature_transform ] && unlink $dir/final.feature_transform
+(cd $dir; ln -s $(basename $feature_transform) final.feature_transform )
+feature_transform=$dir/final.feature_transform
+
+
+###### INITIALIZE THE NNET ######
+echo
+echo "# NN-INITIALIZATION"
+if [ ! -z $nnet_init ]; then
+ echo "# using pre-initialized network '$nnet_init'"
+elif [ ! -z $nnet_proto ]; then
+ echo "# initializing NN from prototype '$nnet_proto'";
+ nnet_init=$dir/nnet.init; log=$dir/log/nnet_initialize.log
+ nnet-initialize --seed=$seed $nnet_proto $nnet_init
+else
+ echo "# getting input/output dims :"
+ # input-dim,
+ get_dim_from=$feature_transform
+ [ ! -z "$dbn" ] && get_dim_from="nnet-concat $feature_transform '$dbn' -|"
+ num_fea=$(feat-to-dim "$feats_tr_10k nnet-forward \"$get_dim_from\" ark:- ark:- |" -)
+
+ # output-dim,
+ [ -z $num_tgt ] && \
+ num_tgt=$(hmm-info --print-args=false $alidir/final.mdl | grep pdfs | awk '{ print $NF }')
+
+ # make network prototype,
+ nnet_proto=$dir/nnet.proto
+ echo "# genrating network prototype $nnet_proto"
+ case "$network_type" in
+ dnn)
+ utils/nnet/make_nnet_proto.py $proto_opts \
+ ${bn_dim:+ --bottleneck-dim=$bn_dim} \
+ $num_fea $num_tgt $hid_layers $hid_dim >$nnet_proto
+ ;;
+ cnn1d)
+ delta_order=$([ -z $delta_opts ] && echo "0" || { echo $delta_opts | tr ' ' '\n' | grep "delta[-_]order" | sed 's:^.*=::'; })
+ echo "Debug : $delta_opts, delta_order $delta_order"
+ utils/nnet/make_cnn_proto.py $cnn_proto_opts \
+ --splice=$splice --delta-order=$delta_order --dir=$dir \
+ $num_fea >$nnet_proto
+ cnn_fea=$(cat $nnet_proto | grep -v '^$' | tail -n1 | awk '{ print $5; }')
+ utils/nnet/make_nnet_proto.py $proto_opts \
+ --no-smaller-input-weights \
+ ${bn_dim:+ --bottleneck-dim=$bn_dim} \
+ "$cnn_fea" $num_tgt $hid_layers $hid_dim >>$nnet_proto
+ ;;
+ cnn2d)
+ delta_order=$([ -z $delta_opts ] && echo "0" || { echo $delta_opts | tr ' ' '\n' | grep "delta[-_]order" | sed 's:^.*=::'; })
+ echo "Debug : $delta_opts, delta_order $delta_order"
+ utils/nnet/make_cnn2d_proto.py $cnn_proto_opts \
+ --splice=$splice --delta-order=$delta_order --dir=$dir \
+ $num_fea >$nnet_proto
+ cnn_fea=$(cat $nnet_proto | grep -v '^$' | tail -n1 | awk '{ print $5; }')
+ utils/nnet/make_nnet_proto.py $proto_opts \
+ --no-smaller-input-weights \
+ ${bn_dim:+ --bottleneck-dim=$bn_dim} \
+ "$cnn_fea" $num_tgt $hid_layers $hid_dim >>$nnet_proto
+ ;;
+ lstm)
+ utils/nnet/make_lstm_proto.py $proto_opts \
+ $num_fea $num_tgt >$nnet_proto
+ ;;
+ blstm)
+ utils/nnet/make_blstm_proto.py $proto_opts \
+ $num_fea $num_tgt >$nnet_proto
+ ;;
+ *) echo "Unknown : --network-type $network_type" && exit 1;
+ esac
+
+ # initialize,
+ nnet_init=$dir/nnet.init
+ echo "# initializing the NN '$nnet_proto' -> '$nnet_init'"
+ nnet-initialize --seed=$seed $nnet_proto $nnet_init
+
+ # optionally prepend dbn to the initialization,
+ if [ ! -z "$dbn" ]; then
+ nnet_init_old=$nnet_init; nnet_init=$dir/nnet_dbn_dnn.init
+ nnet-concat "$dbn" $nnet_init_old $nnet_init
+ fi
+fi
+
+
+###### TRAIN ######
+echo
+echo "# RUNNING THE NN-TRAINING SCHEDULER"
+steps/nnet/train_faster_scheduler.sh \
+ ${scheduler_opts} \
+ ${train_tool:+ --train-tool "$train_tool"} \
+ ${train_tool_opts:+ --train-tool-opts "$train_tool_opts"} \
+ ${feature_transform:+ --feature-transform $feature_transform} \
+ ${split_feats:+ --split-feats $split_feats} \
+ --learn-rate $learn_rate \
+ --momentum $momentum \
+ --start_half_lr $start_half_lr\
+ ${frame_weights:+ --frame-weights "$frame_weights"} \
+ ${utt_weights:+ --utt-weights "$utt_weights"} \
+ ${config:+ --config $config} \
+ $nnet_init "$feats_tr" "$feats_cv" "$labels_tr" "$labels_cv" $dir
+
+echo "$0: Successfuly finished. '$dir'"
+
+sleep 3
+exit 0
diff --git a/egs/wsj/s5/steps/nnet/train_faster_scheduler.sh b/egs/wsj/s5/steps/nnet/train_faster_scheduler.sh
new file mode 100755
index 0000000..8a20442
--- /dev/null
+++ b/egs/wsj/s5/steps/nnet/train_faster_scheduler.sh
@@ -0,0 +1,221 @@
+#!/bin/bash
+
+# Copyright 2012-2017 Brno University of Technology (author: Karel Vesely)
+# Apache 2.0
+
+# Schedules epochs and controls learning rate during the neural network training
+
+# Begin configuration.
+
+# training options,
+learn_rate=0.008
+momentum=0
+l1_penalty=0
+l2_penalty=0
+
+# data processing,
+train_tool="nnet-train-frmshuff"
+train_tool_opts=""
+feature_transform=
+
+split_feats= # int -> number of splits 'feats.scp -> feats.${i}.scp', starting from feats.1.scp,
+ # (data are alredy shuffled and split to N parts),
+ # empty -> no splitting,
+
+# learn rate scheduling,
+max_iters=10
+min_iters=0 # keep training, disable weight rejection, start learn-rate halving as usual,
+keep_lr_iters=0 # fix learning rate for N initial epochs, disable weight rejection,
+dropout_schedule= # dropout-rates for N initial epochs, for example: 0.1,0.1,0.1,0.1,0.1,0.0
+start_halving_impr=0.01
+end_halving_impr=0.001
+halving_factor=0.5
+start_half_lr=5
+randseed=777
+
+
+# misc,
+verbose=0 # 0 No GPU time-stats, 1 with GPU time-stats (slower),
+frame_weights=
+utt_weights=
+
+# End configuration.
+
+echo "$0 $@" # Print the command line for logging
+[ -f path.sh ] && . ./path.sh;
+
+. parse_options.sh || exit 1;
+
+set -euo pipefail
+
+if [ $# != 6 ]; then
+ echo "Usage: $0 <mlp-init> <feats-tr> <feats-cv> <labels-tr> <labels-cv> <exp-dir>"
+ echo " e.g.: $0 0.nnet scp:train.scp scp:cv.scp ark:labels_tr.ark ark:labels_cv.ark exp/dnn1"
+ echo "main options (for others, see top of script file)"
+ echo " --config <config-file> # config containing options"
+ exit 1;
+fi
+
+mlp_init=$1
+feats_tr=$2
+feats_cv=$3
+labels_tr=$4
+labels_cv=$5
+dir=$6
+