diff options
author | Determinant <[email protected]> | 2015-06-01 17:37:04 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-06-01 17:37:04 +0800 |
commit | d8ea67ee420c2fc73085da04de86df023acd98d7 (patch) | |
tree | 6fd6dc7d71df34c5d55db3bc062deebb0fe753ad /examples | |
parent | 3b156cd0cd19aa7db97082161921064a0a871328 (diff) |
...
Diffstat (limited to 'examples')
-rw-r--r-- | examples/tnet_preprocessing_example.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/examples/tnet_preprocessing_example.lua b/examples/tnet_preprocessing_example.lua new file mode 100644 index 0000000..c36463b --- /dev/null +++ b/examples/tnet_preprocessing_example.lua @@ -0,0 +1,46 @@ +require 'libspeech' +require 'layer.affine' +frm_ext = 5 +feat_repo = nerv.TNetFeatureRepo( + "/slfs1/users/mfy43/swb_ivec/train_bp.scp", + "/slfs1/users/mfy43/swb_ivec/plp_0_d_a.conf", + frm_ext) +lab_repo = nerv.TNetLabelRepo( + "/slfs1/users/mfy43/swb_ivec/ref.mlf", + "map", + "/slfs1/users/mfy43/swb_ivec/dict", + "*/", + "lab") +feat_utter = feat_repo:cur_utter() +-- print(feat_utter) +-- lab_utter = lab_repo:get_utter(feat_repo, feat_utter:nrow() - frm_ext * 2) +-- print(lab_utter) +gconf = {mat_type = nerv.CuMatrixFloat} +cf = nerv.ChunkFile("global_transf.nerv", "r") +bias1 = cf:read_chunk("bias1", gconf) +window1 = cf:read_chunk("window1", gconf) +bias2 = cf:read_chunk("bias2", gconf) +window2 = cf:read_chunk("window2", gconf) + +cf2 = nerv.ChunkFile("input.param", "r") +input = cf2:read_chunk("input", gconf) + +step = frm_ext * 2 + 1 +expanded = nerv.CuMatrixFloat(feat_utter:nrow(), feat_utter:ncol() * step) +expanded:expand_frm(nerv.CuMatrixFloat.new_from_host(feat_utter), frm_ext) + +rearranged = expanded:create() +rearranged:rearrange_frm(expanded, step) + +rearranged:add_row(bias1.trans, 1) +rearranged:scale_row(window1.trans) +rearranged:add_row(bias2.trans, 1) +rearranged:scale_row(window2.trans) + +for i = 0, 9 do + row_diff = input.trans[i] - rearranged[i + 5] + for j = 0, row_diff:ncol() - 1 do + nerv.utils.printf("%.8f ", row_diff[j]) + end + nerv.utils.printf("\n") +end |