20 #ifndef KALDI_NNET2_DECODABLE_AM_NNET_H_ 21 #define KALDI_NNET2_DECODABLE_AM_NNET_H_ 42 bool pad_input =
true,
60 log_probs.ApplyFloor(1.0e-20);
64 "Priors in neural network not set up.");
67 log_probs.AddVecToRows(-1.0, priors);
69 log_probs.Scale(prob_scale);
111 bool pad_input =
true,
113 trans_model_(trans_model), am_nnet_(am_nnet), feats_(feats),
114 pad_input_(pad_input), prob_scale_(prob_scale) {
127 "Priors in neural network not set up.");
140 if (feats_) Compute();
147 if (pad_input_)
return feats_->NumRows();
149 int32 ans = feats_->NumRows() - am_nnet_.GetNnet().LeftContext() -
150 am_nnet_.GetNnet().RightContext();
151 if (ans < 0) ans = 0;
187 #endif // KALDI_NNET2_DECODABLE_AM_NNET_H_
This version of DecodableAmNnet is intended for a version of the decoder that processes different utt...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 LeftContext() const
Returns the left-context summed over all the Components...
int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
DecodableInterface provides a link between the (acoustic-modeling and feature-processing) code and th...
const TransitionModel & trans_model_
int32 TransitionIdToPdfFast(int32 trans_id) const
DecodableAmNnet(const TransitionModel &trans_model, const AmNnet &am_nnet, const CuMatrixBase< BaseFloat > &feats, bool pad_input=true, BaseFloat prob_scale=1.0)
CuMatrix< BaseFloat > log_probs_
~DecodableAmNnetParallel()
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void NnetComputation(const Nnet &nnet, const CuMatrixBase< BaseFloat > &input, bool pad_input, CuMatrixBase< BaseFloat > *output)
Does the basic neural net computation, on a sequence of data (e.g.
Matrix< BaseFloat > log_probs_
void Swap(Matrix< Real > *other)
Swaps the contents of *this and *other. Shallow swap.
const CuMatrix< BaseFloat > * feats_
virtual bool IsLastFrame(int32 frame) const
Returns true if this is the last frame.
virtual BaseFloat LogLikelihood(int32 frame, int32 transition_id)
Returns the log likelihood, which will be negated in the decoder.
DecodableAmNnetParallel(const TransitionModel &trans_model, const AmNnet &am_nnet, const CuMatrix< BaseFloat > *feats, bool pad_input=true, BaseFloat prob_scale=1.0)
void Scale(Real alpha)
Multiply each element with a scalar value.
int32 NumTransitionIds() const
Returns the total number of transition-ids (note, these are one-based).
virtual bool IsLastFrame(int32 frame) const
Returns true if this is the last frame.
const VectorBase< BaseFloat > & Priors() const
void AddVecToRows(const Real alpha, const VectorBase< OtherReal > &v)
[each row of *this] += alpha * v
int32 RightContext() const
Returns the right-context summed over all the Components...
virtual int32 NumIndices() const
Returns the number of states in the acoustic model (they will be indexed one-based, i.e.
virtual BaseFloat LogLikelihood(int32 frame, int32 transition_id)
Returns the log likelihood, which will be negated in the decoder.
virtual int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
KALDI_DISALLOW_COPY_AND_ASSIGN(DecodableAmNnet)
const TransitionModel & trans_model_
Matrix for CUDA computing.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
DecodableAmNnet is a decodable object that decodes with a neural net acoustic model of type AmNnet...
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
MatrixIndexT NumRows() const
Dimensions.
void ApplyFloor(Real floor_val)
virtual int32 NumIndices() const
Returns the number of states in the acoustic model (they will be indexed one-based, i.e.
const Nnet & GetNnet() const