From d8ea67ee420c2fc73085da04de86df023acd98d7 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 1 Jun 2015 17:37:04 +0800 Subject: ... --- examples/tnet_preprocessing_example.lua | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 examples/tnet_preprocessing_example.lua (limited to 'examples') 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 -- cgit v1.2.3-70-g09d2