From 85a76e8a91a3114e2061b8ffc1cad979c37a5873 Mon Sep 17 00:00:00 2001 From: Yimmon Zhuang Date: Sat, 10 Oct 2015 19:25:17 +0800 Subject: disable batch when sequence training --- kaldi_seq/src/kaldi_mpe.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'kaldi_seq/src/kaldi_mpe.cpp') diff --git a/kaldi_seq/src/kaldi_mpe.cpp b/kaldi_seq/src/kaldi_mpe.cpp index 8cdf010..60384e2 100644 --- a/kaldi_seq/src/kaldi_mpe.cpp +++ b/kaldi_seq/src/kaldi_mpe.cpp @@ -205,12 +205,11 @@ extern "C" { // Select the GPU #if HAVE_CUDA == 1 - CuDevice::Instantiate().SelectGpuId(use_gpu); + CuDevice::Instantiate().SelectGpuId(mpe->use_gpu); #endif // Read the class-frame-counts, compute priors mpe->log_prior = new PdfPrior(prior_opts); - PdfPrior &log_prior = *(mpe->log_prior); // Read transition model mpe->trans_model = new TransitionModel; @@ -256,7 +255,7 @@ extern "C" { return 0; } - assert(sizeof(BaseFloat) == sizeof(float)); + //assert(sizeof(BaseFloat) == sizeof(float)); // 1) get the features, numerator alignment mpe->ref_ali = mpe->ref_ali_reader->Value(utt); long mat_nrow = mat->nrow, mat_ncol = mat->ncol; @@ -309,8 +308,9 @@ extern "C" { NervMatrix * calc_diff_mpe(KaldiMPE * mpe, NervMatrix * mat, const char * key) { std::string utt(key); - assert(sizeof(BaseFloat) == sizeof(float)); + //assert(sizeof(BaseFloat) == sizeof(float)); + CuMatrix nnet_diff; kaldi::Matrix nnet_out_h; nnet_out_h.Resize(mat->nrow, mat->ncol, kUndefined); @@ -327,9 +327,10 @@ extern "C" { PdfPriorOptions &prior_opts = *(mpe->prior_opts); if (prior_opts.class_frame_counts != "") { CuMatrix nnet_out; - nnet_out.Resize(mat->nrow, mat->ncol, kUndefined); + nnet_out.Resize(nnet_out_h.NumRows(), nnet_out_h.NumCols(), kUndefined); nnet_out.CopyFromMat(nnet_out_h); mpe->log_prior->SubtractOnLogpost(&nnet_out); + nnet_out_h.Resize(nnet_out.NumRows(), nnet_out.NumCols(), kUndefined); nnet_out.CopyToMat(&nnet_out_h); nnet_out.Resize(0,0); } @@ -353,7 +354,6 @@ extern "C" { } // 6) convert the Posterior to a matrix, - CuMatrix nnet_diff; PosteriorToMatrixMapped(post, *(mpe->trans_model), &nnet_diff); nnet_diff.Scale(-1.0); // need to flip the sign of derivative, @@ -366,6 +366,7 @@ extern "C" { << " frames," << " diff-range(" << nnet_diff.Min() << "," << nnet_diff.Max() << ")"; + nnet_out_h.Resize(nnet_diff.NumRows(), nnet_diff.NumCols(), kUndefined); nnet_diff.CopyToMat(&nnet_out_h); nnet_diff.Resize(0,0); // release GPU memory, -- cgit v1.2.3