36 std::vector<Nnet*> nnet_ensemble):
37 config_(config), nnet_ensemble_(nnet_ensemble) {
40 bool first_time =
true;
57 std::vector<CuMatrix<BaseFloat> > post_mat;
66 post_avg.AddMat(1.0, post_mat[i]);
71 std::vector<MatrixElement<BaseFloat> > sv_labels;
72 std::vector<Int32Pair > sv_labels_ind;
73 sv_labels.reserve(
buffer_.size());
74 sv_labels_ind.reserve(
buffer_.size());
77 "Currently this code only supports single-frame egs.");
78 const std::vector<std::pair<int32,BaseFloat> > &labels =
buffer_[m].labels[0];
79 for (
size_t i = 0;
i < labels.size();
i++) {
81 tmp = {m, labels[
i].first, labels[
i].second};
82 sv_labels.push_back(tmp);
83 sv_labels_ind.push_back(
MakePair(m, labels[
i].first));
87 post_avg.Scale(
beta_);
88 post_avg.AddElements(1.0, sv_labels);
93 post_mat[
i].ApplyLog();
94 std::vector<BaseFloat> log_post_correct;
95 log_post_correct.resize(sv_labels_ind.size());
96 post_mat[
i].Lookup(sv_labels_ind, &(log_post_correct[0]));
97 BaseFloat log_prob_this_net = std::accumulate(log_post_correct.begin(),
98 log_post_correct.end(),
110 bool first_time =
false;
117 KALDI_LOG <<
"Averaged cross-entropy between the supervision labels and the output is " 129 KALDI_LOG <<
"Doing partial minibatch of size " 133 bool first_time =
false;
double avg_logprob_this_phase_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
NnetExample is the input data and corresponding label (or labels) for one or more frames of input...
static Int32Pair MakePair(int32 first, int32 second)
int32 minibatches_seen_this_phase_
int32 minibatches_per_phase
void BeginNewPhase(bool first_time)
std::vector< NnetExample > buffer_
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
NnetEnsembleTrainer(const NnetEnsembleTrainerConfig &config, std::vector< Nnet *> nnet_ensemble)
void InvertElements()
invert the matrix by elements.
void MulElements(const CuMatrixBase< Real > &A)
Multiply two matrices elementwise: C = C .* A.
void TrainOnExample(const NnetExample &value)
TrainOnExample will take the example and add it to a buffer; if we've reached the minibatch size it w...
#define KALDI_ASSERT(cond)
std::vector< NnetUpdater * > updater_ensemble_
std::vector< Nnet * > nnet_ensemble_
NnetEnsembleTrainerConfig config_