summaryrefslogtreecommitdiff
path: root/kaldi_seq/src
diff options
context:
space:
mode:
authorYimmon Zhuang <[email protected]>2015-10-10 19:25:17 +0800
committerYimmon Zhuang <[email protected]>2015-10-10 19:25:17 +0800
commit85a76e8a91a3114e2061b8ffc1cad979c37a5873 (patch)
treed9efd7ed8c74cf2ef408a96b6acd08e4943fc590 /kaldi_seq/src
parentccbafeb6f44cee8f23eb440a670ce16fdda58682 (diff)
disable batch when sequence training
Diffstat (limited to 'kaldi_seq/src')
-rw-r--r--kaldi_seq/src/kaldi_mmi.cpp3
-rw-r--r--kaldi_seq/src/kaldi_mpe.cpp13
2 files changed, 8 insertions, 8 deletions
diff --git a/kaldi_seq/src/kaldi_mmi.cpp b/kaldi_seq/src/kaldi_mmi.cpp
index a64abd0..ea9b4f1 100644
--- a/kaldi_seq/src/kaldi_mmi.cpp
+++ b/kaldi_seq/src/kaldi_mmi.cpp
@@ -164,12 +164,11 @@ extern "C" {
// Select the GPU
#if HAVE_CUDA == 1
- CuDevice::Instantiate().SelectGpuId(use_gpu);
+ CuDevice::Instantiate().SelectGpuId(mmi->use_gpu);
#endif
// Read the class-frame-counts, compute priors
mmi->log_prior = new PdfPrior(prior_opts);
- PdfPrior &log_prior = *(mmi->log_prior);
// Read transition model
mmi->trans_model = new TransitionModel;
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<BaseFloat> nnet_diff;
kaldi::Matrix<BaseFloat> 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<BaseFloat> 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<BaseFloat> 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,