Classes | |
class | AdditiveNoiseComponent |
This is a bit similar to dropout but adding (not multiplying) Gaussian noise with a given standard deviation. More... | |
class | AffineComponent |
class | AffineComponentPreconditioned |
class | AffineComponentPreconditionedOnline |
Keywords: natural gradient descent, NG-SGD, naturalgradient. More... | |
class | AmNnet |
class | BlockAffineComponent |
class | BlockAffineComponentPreconditioned |
class | ChunkInfo |
ChunkInfo is a class whose purpose is to describe the structure of matrices holding features. More... | |
class | Component |
Abstract class, basic element of the network, it is a box with defined inputs, outputs, and tranformation functions interface. More... | |
class | Convolutional1dComponent |
Convolutional1dComponent implements convolution over frequency axis. More... | |
class | DctComponent |
Discrete cosine transform. More... | |
class | DecodableAmNnet |
DecodableAmNnet is a decodable object that decodes with a neural net acoustic model of type AmNnet. More... | |
class | DecodableAmNnetParallel |
This version of DecodableAmNnet is intended for a version of the decoder that processes different utterances with multiple threads. More... | |
class | DecodableNnet2Online |
This Decodable object for class nnet2::AmNnet takes feature input from class OnlineFeatureInterface, unlike, say, class DecodableAmNnet which takes feature input from a matrix. More... | |
struct | DecodableNnet2OnlineOptions |
class | DiscriminativeExampleSplitter |
For each frame, judge: More... | |
class | DiscriminativeExamplesRepository |
This struct stores neural net training examples to be used in multi-threaded training. More... | |
struct | DiscriminativeNnetExample |
This struct is used to store the information we need for discriminative training (MMI or MPE). More... | |
class | DiscTrainParallelClass |
class | DoBackpropParallelClass |
class | DropoutComponent |
This Component, if present, randomly zeroes half of the inputs and multiplies the other half by two. More... | |
class | ExamplesRepository |
This class stores neural net training examples to be used in multi-threaded training. More... | |
class | FastNnetCombiner |
class | FisherComputationClass |
class | FixedAffineComponent |
FixedAffineComponent is an affine transform that is supplied at network initialization time and is not trainable. More... | |
class | FixedBiasComponent |
FixedBiasComponent applies a fixed per-element bias; it's similar to the AddShift component in the nnet1 setup (and only needed for nnet1 model conversion. More... | |
class | FixedLinearComponent |
FixedLinearComponent is a linear transform that is supplied at network initialization time and is not trainable. More... | |
class | FixedScaleComponent |
FixedScaleComponent applies a fixed per-element scale; it's similar to the Rescale component in the nnet1 setup (and only needed for nnet1 model conversion). More... | |
class | LimitRankClass |
class | LogSoftmaxComponent |
class | MaxoutComponent |
class | MaxpoolingComponent |
MaxPoolingComponent : Maxpooling component was firstly used in ConvNet for selecting an representative activation in an area. More... | |
class | Nnet |
struct | NnetCombineAconfig |
struct | NnetCombineConfig |
Configuration class that controls neural net combination, where we combine a number of neural nets, trying to find for each layer the optimal weighted combination of the different neural-net parameters. More... | |
struct | NnetCombineFastConfig |
Configuration class that controls neural net combination, where we combine a number of neural nets, trying to find for each layer the optimal weighted combination of the different neural-net parameters. More... | |
class | NnetComputer |
struct | NnetDiscriminativeStats |
struct | NnetDiscriminativeUpdateOptions |
class | NnetDiscriminativeUpdater |
class | NnetEnsembleTrainer |
struct | NnetEnsembleTrainerConfig |
struct | NnetExample |
NnetExample is the input data and corresponding label (or labels) for one or more frames of input, used for standard cross-entropy training of neural nets (and possibly for other objective functions). More... | |
class | NnetExampleBackgroundReader |
struct | NnetFixConfig |
struct | NnetLimitRankOpts |
struct | NnetMixupConfig |
class | NnetOnlineComputer |
struct | NnetRescaleConfig |
class | NnetRescaler |
struct | NnetShrinkConfig |
Configuration class that controls neural net "shrinkage" which is actually a scaling on the parameters of each of the updatable layers. More... | |
struct | NnetSimpleTrainerConfig |
class | NnetStats |
struct | NnetStatsConfig |
class | NnetUpdater |
struct | NnetWidenConfig |
Configuration class that controls neural net "widening", which means increasing the dimension of the hidden layers of an already-trained neural net. More... | |
class | NonlinearComponent |
This kind of Component is a base-class for things like sigmoid and softmax. More... | |
class | NormalizeComponent |
class | OnlinePreconditioner |
Keywords for search: natural gradient, naturalgradient, NG-SGD. More... | |
class | OnlinePreconditionerSimple |
class | PermuteComponent |
PermuteComponent does a permutation of the dimensions (by default, a fixed random permutation, but it may be specified). More... | |
class | PnormComponent |
class | PowerComponent |
Take the absoute values of an input vector to a power. More... | |
class | RandomComponent |
class | RectifiedLinearComponent |
class | ScaleComponent |
class | SigmoidComponent |
class | SoftHingeComponent |
class | SoftmaxComponent |
class | SpliceComponent |
Splices a context window of frames together [over time]. More... | |
class | SpliceMaxComponent |
This is as SpliceComponent but outputs the max of any of the inputs (taking the max across time). More... | |
struct | SplitDiscriminativeExampleConfig |
Config structure for SplitExample, for splitting discriminative training examples. More... | |
struct | SplitExampleStats |
This struct exists only for diagnostic purposes. More... | |
class | SumGroupComponent |
class | TanhComponent |
class | UpdatableComponent |
Class UpdatableComponent is a Component which has trainable parameters and contains some global parameters for stochastic gradient descent (learning rate, L2 regularization constant). More... | |
Functions | |
void | UnitTestAmNnet () |
static void | GetUpdateDirection (const std::vector< Nnet > &nnets, Nnet *direction) |
static void | AddDirection (const Nnet &orig_nnet, const Nnet &direction, const VectorBase< BaseFloat > &scales, Nnet *dest) |
Sets "dest" to orig_nnet plus "direction", with each updatable component of "direction" first scaled by the appropriate scale. More... | |
static BaseFloat | ComputeObjfAndGradient (const std::vector< NnetExample > &validation_set, const Vector< double > &scale_params, const Nnet &orig_nnet, const Nnet &direction, Vector< double > *gradient) |
void | CombineNnetsA (const NnetCombineAconfig &config, const std::vector< NnetExample > &validation_set, const std::vector< Nnet > &nnets, Nnet *nnet_out) |
void | CombineNnetsFast (const NnetCombineFastConfig &combine_config, const std::vector< NnetExample > &validation_set, const std::vector< Nnet > &nnets_in, Nnet *nnet_out) |
static void | CombineNnets (const Vector< BaseFloat > &scale_params, const std::vector< Nnet > &nnets, Nnet *dest) |
static int32 | GetInitialModel (const std::vector< NnetExample > &validation_set, const std::vector< Nnet > &nnets) |
Returns an integer saying which model to use: either 0 ... More... | |
static void | GetInitialScaleParams (const NnetCombineConfig &combine_config, const std::vector< NnetExample > &validation_set, const std::vector< Nnet > &nnets, Vector< double > *scale_params) |
static double | ComputeObjfAndGradient (const std::vector< NnetExample > &validation_set, const Vector< double > &scale_params, const std::vector< Nnet > &nnets, bool debug, Vector< double > *gradient) |
void | CombineNnets (const NnetCombineConfig &combine_config, const std::vector< NnetExample > &validation_set, const std::vector< Nnet > &nnets, Nnet *nnet_out) |
static void | GiveNnetCorrectTopology (Nnet *nnet, AffineComponent **affine_component, SoftmaxComponent **softmax_component, SumGroupComponent **sum_group_component) |
This function makes sure the neural net ends with a SumGroupComponent. More... | |
void | MixupNnet (const NnetMixupConfig &mixup_config, Nnet *nnet) |
This function works as follows. More... | |
void | UnitTestGenericComponentInternal (const Component &component, const ChunkInfo in_info, const ChunkInfo out_info) |
void | UnitTestGenericComponentInternal (const Component &component) |
void | UnitTestSigmoidComponent () |
template<class T > | |
void | UnitTestGenericComponent (std::string extra_str="") |
void | UnitTestMaxoutComponent () |
void | UnitTestPnormComponent () |
void | UnitTestMaxpoolingComponent () |
void | UnitTestAffineComponent () |
void | UnitTestConvolutional1dComponent () |
void | UnitTestDropoutComponent () |
void | UnitTestAdditiveNoiseComponent () |
void | UnitTestScaleComponent () |
void | UnitTestAffineComponentPreconditioned () |
void | UnitTestAffineComponentPreconditionedOnline () |
void | UnitTestBlockAffineComponent () |
void | UnitTestBlockAffineComponentPreconditioned () |
void | UnitTestSumGroupComponent () |
void | UnitTestDctComponent () |
void | UnitTestFixedLinearComponent () |
void | UnitTestFixedAffineComponent () |
void | UnitTestFixedScaleComponent () |
void | UnitTestFixedBiasComponent () |
void | UnitTestParsing () |
void | UnitTestSpliceComponent () |
void | BasicDebugTestForSpliceMax (bool output=false) |
static void | ExpectOneOrTwoTokens (std::istream &is, bool binary, const std::string &token1, const std::string &token2) |
bool | ParseFromString (const std::string &name, std::string *string, int32 *param) |
Functions used in Init routines. More... | |
bool | ParseFromString (const std::string &name, std::string *string, bool *param) |
This version is for parameters of type bool, which can appear as any string beginning with f, F, t or T. More... | |
bool | ParseFromString (const std::string &name, std::string *string, BaseFloat *param) |
This version is for parameters of type BaseFloat. More... | |
bool | ParseFromString (const std::string &name, std::string *string, std::string *param) |
bool | ParseFromString (const std::string &name, std::string *string, std::vector< int32 > *param) |
This version is for parameters of type std::vector<int32>; it expects them as a colon-separated list, without spaces. More... | |
void | NnetDiscriminativeUpdateParallel (const AmNnet &am_nnet, const TransitionModel &tmodel, const NnetDiscriminativeUpdateOptions &opts, int32 num_threads, SequentialDiscriminativeNnetExampleReader *example_reader, Nnet *nnet_to_update, NnetDiscriminativeStats *stats) |
void | NnetDiscriminativeUpdate (const AmNnet &am_nnet, const TransitionModel &tmodel, const NnetDiscriminativeUpdateOptions &opts, const DiscriminativeNnetExample &eg, Nnet *nnet_to_update, NnetDiscriminativeStats *stats) |
Does the neural net computation, lattice forward-backward, and backprop, for either the MMI, MPFE or SMBR objective functions. More... | |
void | UnitTestNnetCompute () |
void | UnitTestNnetComputeChunked () |
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. More... | |
void | NnetComputationChunked (const Nnet &nnet, const CuMatrixBase< BaseFloat > &input, int32 chunk_size, CuMatrixBase< BaseFloat > *output) |
Does the basic neural net computation, on a sequence of data (e.g. More... | |
BaseFloat | NnetGradientComputation (const Nnet &nnet, const CuMatrixBase< BaseFloat > &input, bool pad_input, const Posterior &pdf_post, Nnet *nnet_to_update) |
BaseFloat | NnetGradientComputation (const Nnet &nnet, const MatrixBase< BaseFloat > &input, bool pad_input, BaseFloat utterance_weight, const std::vector< int32 > &labels, Nnet *nnet_to_update) |
Does the neural net computation and backprop, given input and labels. More... | |
void | UnitTestSolvePackingProblem () |
bool | LatticeToDiscriminativeExample (const std::vector< int32 > &alignment, const Matrix< BaseFloat > &feats, const CompactLattice &clat, BaseFloat weight, int32 left_context, int32 right_context, DiscriminativeNnetExample *eg) |
Converts lattice to discriminative training example. More... | |
void | SplitDiscriminativeExample (const SplitDiscriminativeExampleConfig &config, const TransitionModel &tmodel, const DiscriminativeNnetExample &eg, std::vector< DiscriminativeNnetExample > *egs_out, SplitExampleStats *stats_out) |
Split a "discriminative example" into multiple pieces, splitting where the lattice has "pinch points". More... | |
void | ExciseDiscriminativeExample (const SplitDiscriminativeExampleConfig &config, const TransitionModel &tmodel, const DiscriminativeNnetExample &eg, std::vector< DiscriminativeNnetExample > *egs_out, SplitExampleStats *stats_out) |
Remove unnecessary frames from discriminative training example. More... | |
void | UpdateHash (const TransitionModel &tmodel, const DiscriminativeNnetExample &eg, std::string criterion, bool drop_frames, bool one_silence_class, Matrix< double > *hash, double *num_weight, double *den_weight, double *tot_t) |
This function is used in code that tests the functionality that we provide here, about splitting and excising nnet examples. More... | |
void | ExampleToPdfPost (const TransitionModel &tmodel, const std::vector< int32 > &silence_phones, std::string criterion, bool drop_frames, bool one_silence_class, const DiscriminativeNnetExample &eg, Posterior *post) |
Given a discriminative training example, this function works out posteriors at the pdf level (note: these are "discriminative-training posteriors" that may be positive or negative. More... | |
void | SolvePackingProblem (BaseFloat max_cost, const std::vector< BaseFloat > &costs, std::vector< std::vector< size_t > > *groups) |
This function solves the "packing problem" using the "first fit" algorithm. More... | |
void | AppendDiscriminativeExamples (const std::vector< const DiscriminativeNnetExample * > &input, DiscriminativeNnetExample *output) |
Appends the given vector of examples (which must be non-empty) into a single output example (called by CombineExamples, which might be a more convenient interface). More... | |
void | CombineDiscriminativeExamples (int32 max_length, const std::vector< DiscriminativeNnetExample > &input, std::vector< DiscriminativeNnetExample > *output) |
This function is used to combine multiple discriminative-training examples (each corresponding to a segment of a lattice), into one. More... | |
bool | HasSimpleLabels (const NnetExample &eg, std::vector< int32 > *simple_labels) |
void | FixNnet (const NnetFixConfig &config, Nnet *nnet) |
int32 | IndexOfSoftmaxLayer (const Nnet &nnet) |
If "nnet" has exactly one softmax layer, this function will return its index; otherwise it will return -1. More... | |
void | InsertComponents (const Nnet &src_nnet, int32 c, Nnet *dest_nnet) |
Inserts the components of one neural network into a particular place in the other one. More... | |
void | ReplaceLastComponents (const Nnet &src_nnet, int32 num_to_remove, Nnet *dest_nnet) |
Removes the last "num_to_remove" components and adds the components from "src_nnet". More... | |
void | LimitRankParallel (const NnetLimitRankOpts &opts, Nnet *nnet) |
This function limits the rank of each affine transform in the neural net, by zeroing out the smallest singular values. More... | |
void | UnitTestNnet () |
Nnet * | GenRandomNnet (int32 input_dim, int32 output_dim) |
This function generates a random neural net, for testing purposes. More... | |
void | UnitTestPreconditionDirectionsOnline () |
void | UnitTestPreconditionDirections () |
void | PreconditionDirections (const CuMatrixBase< BaseFloat > &R, double lambda, CuMatrixBase< BaseFloat > *P) |
See below for comment. More... | |
void | PreconditionDirectionsAlpha (const CuMatrixBase< BaseFloat > &R, double alpha, CuMatrixBase< BaseFloat > *P) |
This wrapper for PreconditionDirections computes lambda using = /(N D) trace(R^T, R), and calls PreconditionDirections. More... | |
void | PreconditionDirectionsAlphaRescaled (const CuMatrixBase< BaseFloat > &R, double alpha, CuMatrixBase< BaseFloat > *P) |
This wrapper for PreconditionDirections computes lambda using = /(N D) trace(R^T, R), and calls PreconditionDirections. More... | |
void | GetNnetStats (const NnetStatsConfig &config, const Nnet &nnet, std::vector< NnetStats > *stats) |
double | DoBackpropParallel (const Nnet &nnet, int32 minibatch_size, SequentialNnetExampleReader *example_reader, double *tot_weight, Nnet *nnet_to_update) |
This function is similar to "DoBackprop" in nnet-update.h This function computes the objective function and either updates the model or computes parameter gradients. More... | |
double | DoBackpropSingleThreaded (const Nnet &nnet, int32 minibatch_size, const std::vector< NnetExample > &egs, double *tot_weight, Nnet *nnet_to_update) |
double | DoBackpropParallel (const Nnet &nnet, int32 minibatch_size, int32 num_threads, const std::vector< NnetExample > &examples, double *num_frames, Nnet *nnet_to_update) |
This version of DoBackpropParallel takes a vector of examples, and will typically be used to compute the exact gradient. More... | |
double | ComputeNnetObjfParallel (const Nnet &nnet, int32 minibatch_size, int32 num_threads, const std::vector< NnetExample > &examples, double *num_frames) |
This is basically to clarify the fact that DoBackpropParallel will also work with nnet_to_update == NULL, and will compute the objf. More... | |
void | FormatNnetInput (const Nnet &nnet, const std::vector< NnetExample > &data, Matrix< BaseFloat > *mat) |
Takes the input to the nnet for a minibatch of examples, and formats as a single matrix. More... | |
BaseFloat | TotalNnetTrainingWeight (const std::vector< NnetExample > &egs) |
Returns the total weight summed over all the examples... More... | |
double | ComputeNnetObjf (const Nnet &nnet, const std::vector< NnetExample > &examples, double *tot_accuracy=NULL) |
Computes objective function over a minibatch. More... | |
double | DoBackprop (const Nnet &nnet, const std::vector< NnetExample > &examples, Nnet *nnet_to_update, double *tot_accuracy=NULL) |
This function computes the objective function and either updates the model or adds to parameter gradients. More... | |
double | DoBackprop (const Nnet &nnet, const std::vector< NnetExample > &examples, Matrix< BaseFloat > *examples_formatted, Nnet *nnet_to_update, double *tot_accuracy=NULL) |
This version of DoBackprop allows you to separately call FormatNnetInput and provide the result to DoBackprop; this can be useful when using GPUs because the call to FormatNnetInput can be in a separate thread from the one that uses the GPU. More... | |
double | ComputeNnetGradient (const Nnet &nnet, const std::vector< NnetExample > &examples, int32 batch_size, Nnet *gradient) |
ComputeNnetGradient is mostly used to compute gradients on validation sets; it divides the example into batches and calls DoBackprop() on each. More... | |
double | ComputeNnetObjf (const Nnet &nnet, const std::vector< NnetExample > &examples, int32 minibatch_size, double *tot_accuracy=NULL) |
This version of ComputeNnetObjf breaks up the examples into multiple minibatches to do the computation. More... | |
void | UnitTestNnetDecodable () |
void | RescaleNnet (const NnetRescaleConfig &rescale_config, const std::vector< NnetExample > &examples, Nnet *nnet) |
static BaseFloat | ComputeObjfAndGradient (const std::vector< NnetExample > &validation_set, const Vector< double > &log_scale_params, const Nnet &nnet, Vector< double > *gradient) |
void | ShrinkNnet (const NnetShrinkConfig &shrink_config, const std::vector< NnetExample > &validation_set, Nnet *nnet) |
static Int32Pair | MakePair (int32 first, int32 second) |
int64 | TrainNnetSimple (const NnetSimpleTrainerConfig &config, Nnet *nnet, SequentialNnetExampleReader *reader, double *tot_weight=NULL, double *tot_logprob=NULL) |
Train on all the examples it can read from the reader. More... | |
void | WidenNnet (const NnetWidenConfig &widen_config, Nnet *nnet) |
This function widens a neural network by increasing the hidden-layer dimensions to the target. More... | |
BaseFloat | KlDivergence (const Vector< BaseFloat > &p, const Vector< BaseFloat > &q) |
void | PrintPriorDiagnostics (const Vector< BaseFloat > &old_priors, const Vector< BaseFloat > &new_priors) |
int32 | GetCount (double expected_count) |
void | AverageConstPart (int32 const_feat_dim, DiscriminativeNnetExample *eg) |
static void | ProcessFile (const MatrixBase< BaseFloat > &feats, const Posterior &pdf_post, const std::string &utt_id, int32 left_context, int32 right_context, int32 num_frames, int32 const_feat_dim, int64 *num_frames_written, int64 *num_egs_written, NnetExampleWriter *example_writer) |
static void | ProcessFile (const MatrixBase< BaseFloat > &feats, const Posterior &pdf_post, const std::string &utt_id, const Vector< BaseFloat > &weights, int32 left_context, int32 right_context, int32 const_feat_dim, BaseFloat keep_proportion, BaseFloat weight_threshold, bool use_frame_selection, bool use_frame_weights, int64 *num_frames_written, int64 *num_frames_skipped, NnetExampleWriter *example_writer) |
void | SetMaxChange (BaseFloat max_change, Nnet *nnet) |
void | SetPriors (const TransitionModel &tmodel, const Vector< double > &transition_accs, double prior_floor, AmNnet *am_nnet) |
Variables | |
static bool | nnet_example_warned_left = false |
static bool | nnet_example_warned_right = false |
Definition at line 181 of file nnet-example.h.
typedef TableWriter<KaldiObjectHolder<NnetExample > > NnetExampleWriter |
Definition at line 92 of file nnet-example.h.
typedef RandomAccessTableReader<KaldiObjectHolder<DiscriminativeNnetExample > > RandomAccessDiscriminativeNnetExampleReader |
Definition at line 185 of file nnet-example.h.
Definition at line 94 of file nnet-example.h.
typedef SequentialTableReader<KaldiObjectHolder<DiscriminativeNnetExample > > SequentialDiscriminativeNnetExampleReader |
Definition at line 183 of file nnet-example.h.
Definition at line 93 of file nnet-example.h.
|
static |
Sets "dest" to orig_nnet plus "direction", with each updatable component of "direction" first scaled by the appropriate scale.
Definition at line 52 of file combine-nnet-a.cc.
References Nnet::AddNnet().
Referenced by CombineNnetsA(), and ComputeObjfAndGradient().
void AppendDiscriminativeExamples | ( | const std::vector< const DiscriminativeNnetExample * > & | input, |
DiscriminativeNnetExample * | output | ||
) |
Appends the given vector of examples (which must be non-empty) into a single output example (called by CombineExamples, which might be a more convenient interface).
When combining examples it directly appends the features, and then adds a "fake" segment to the lattice and alignment in between, padding with transition-ids that are all ones. This is necessary in case the network needs acoustic context, and only because of a kind of limitation in the nnet training code that doesn't support varying 'chunk' sizes within a minibatch.
Will fail if all the input examples don't have the same weight (this will normally be 1.0 anyway), or if the feature dimension (i.e. basic feature dimension plus spk_info dimension) differs between the examples.
Definition at line 891 of file nnet-example-functions.cc.
References DiscriminativeNnetExample::den_lat, rnnlm::i, DiscriminativeNnetExample::input_frames, KALDI_ASSERT, kaldi::kUndefined, DiscriminativeNnetExample::left_context, DiscriminativeNnetExample::num_ali, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), CompactLatticeWeightTpl< WeightType, IntType >::One(), MatrixBase< Real >::Range(), Matrix< Real >::Resize(), DiscriminativeNnetExample::spk_info, and DiscriminativeNnetExample::weight.
Referenced by CombineDiscriminativeExamples(), and SplitExampleStats::SplitExampleStats().
void kaldi::nnet2::AverageConstPart | ( | int32 | const_feat_dim, |
DiscriminativeNnetExample * | eg | ||
) |
Definition at line 42 of file nnet-copy-egs-discriminative.cc.
References DiscriminativeNnetExample::input_frames, KALDI_ASSERT, MatrixBase< Real >::NumCols(), MatrixBase< Real >::Range(), and DiscriminativeNnetExample::spk_info.
Referenced by main().
void kaldi::nnet2::BasicDebugTestForSpliceMax | ( | bool | output = false | ) |
Definition at line 805 of file nnet-component-test.cc.
References SpliceMaxComponent::Backprop(), rnnlm::i, SpliceMaxComponent::Init(), KALDI_LOG, SpliceMaxComponent::OutputDim(), and SpliceMaxComponent::Propagate().
Referenced by main().
void CombineDiscriminativeExamples | ( | int32 | max_length, |
const std::vector< DiscriminativeNnetExample > & | input, | ||
std::vector< DiscriminativeNnetExample > * | output | ||
) |
This function is used to combine multiple discriminative-training examples (each corresponding to a segment of a lattice), into one.
It combines examples into groups such that each group will have a total length (number of rows of the feature matrix) less than or equal to max_length. However, if individual examples are longer than max_length they will still be processed; they will be given their own group.
See also the documentation for AppendDiscriminativeExamples() which gives more details on how we append the examples.
Will fail if all the input examples don't have the same weight (this will normally be 1.0 anyway).
If the spk_info variables are non-empty, it will move them into the features of the output, so the spk_info of the output will be empty but the appropriate speaker vectors will be appended to each row of the features.
Definition at line 970 of file nnet-example-functions.cc.
References AppendDiscriminativeExamples(), rnnlm::i, rnnlm::j, and SolvePackingProblem().
Referenced by main(), and SplitExampleStats::SplitExampleStats().
|
static |
Definition at line 28 of file combine-nnet.cc.
References Nnet::AddNnet(), KALDI_ASSERT, rnnlm::n, kaldi::nnet3::NumUpdatableComponents(), and Nnet::ScaleComponents().
Referenced by CombineNnets(), FastNnetCombiner::ComputeCurrentNnet(), ComputeObjfAndGradient(), FastNnetCombiner::FastNnetCombiner(), GetInitialModel(), FastNnetCombiner::GetInitialModel(), main(), and NnetCombineConfig::Register().
void CombineNnets | ( | const NnetCombineConfig & | combine_config, |
const std::vector< NnetExample > & | validation_set, | ||
const std::vector< Nnet > & | nnets, | ||
Nnet * | nnet_out | ||
) |
Definition at line 193 of file combine-nnet.cc.
References CombineNnets(), ComputeObjfAndGradient(), VectorBase< Real >::CopyFromVec(), MatrixBase< Real >::CopyRowsFromVec(), VectorBase< Real >::Dim(), OptimizeLbfgs< Real >::DoStep(), LbfgsOptions::first_step_impr, GetInitialScaleParams(), OptimizeLbfgs< Real >::GetProposedValue(), OptimizeLbfgs< Real >::GetValue(), rnnlm::i, NnetCombineConfig::initial_impr, KALDI_ASSERT, KALDI_LOG, KALDI_VLOG, LbfgsOptions::m, LbfgsOptions::minimize, NnetCombineConfig::num_bfgs_iters, and NnetCombineConfig::test_gradient.
void CombineNnetsA | ( | const NnetCombineAconfig & | config, |
const std::vector< NnetExample > & | validation_set, | ||
const std::vector< Nnet > & | nnets, | ||
Nnet * | nnet_out | ||
) |
Definition at line 102 of file combine-nnet-a.cc.
References AddDirection(), ComputeObjfAndGradient(), VectorBase< Real >::CopyFromVec(), VectorBase< Real >::Dim(), OptimizeLbfgs< Real >::DoStep(), LbfgsOptions::first_step_length, Nnet::GetComponent(), OptimizeLbfgs< Real >::GetProposedValue(), GetUpdateDirection(), OptimizeLbfgs< Real >::GetValue(), rnnlm::i, NnetCombineAconfig::initial_step, rnnlm::j, KALDI_ASSERT, KALDI_LOG, KALDI_VLOG, KALDI_WARN, UpdatableComponent::LearningRate(), LbfgsOptions::m, NnetCombineAconfig::max_learning_rate_factor, NnetCombineAconfig::min_learning_rate, NnetCombineAconfig::min_learning_rate_factor, LbfgsOptions::minimize, NnetCombineAconfig::num_bfgs_iters, Nnet::NumComponents(), kaldi::nnet3::NumUpdatableComponents(), NnetCombineAconfig::overshoot, VectorBase< Real >::Set(), UpdatableComponent::SetLearningRate(), and NnetCombineAconfig::valid_impr_thresh.
Referenced by NnetCombineAconfig::Register().
void CombineNnetsFast | ( | const NnetCombineFastConfig & | combine_config, |
const std::vector< NnetExample > & | validation_set, | ||
const std::vector< Nnet > & | nnets_in, | ||
Nnet * | nnet_out | ||
) |
Definition at line 430 of file combine-nnet-fast.cc.
Referenced by main(), and NnetCombineFastConfig::Register().
double ComputeNnetGradient | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | examples, | ||
int32 | batch_size, | ||
Nnet * | gradient | ||
) |
ComputeNnetGradient is mostly used to compute gradients on validation sets; it divides the example into batches and calls DoBackprop() on each.
It returns the *average* objective function per frame.
Definition at line 302 of file nnet-update.cc.
References DoBackprop(), rnnlm::i, and Nnet::SetZero().
Referenced by ComputeObjfAndGradient(), and main().
double ComputeNnetObjf | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | examples, | ||
double * | tot_accuracy = NULL |
||
) |
Computes objective function over a minibatch.
Returns the *total* weighted objective function over the minibatch. If tot_accuracy != NULL, it outputs to that pointer the total (weighted) accuracy.
Definition at line 258 of file nnet-update.cc.
References NnetUpdater::ComputeForMinibatch().
Referenced by ComputeNnetObjf(), DoBackprop(), GetInitialModel(), main(), and DoBackpropParallelClass::operator()().
double ComputeNnetObjf | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | examples, | ||
int32 | minibatch_size, | ||
double * | tot_accuracy = NULL |
||
) |
This version of ComputeNnetObjf breaks up the examples into multiple minibatches to do the computation.
Returns the *total* (weighted) objective function. If tot_accuracy != NULL, it outputs to that pointer the total (weighted) accuracy.
Definition at line 329 of file nnet-update.cc.
References ComputeNnetObjf(), and rnnlm::i.
|
inline |
This is basically to clarify the fact that DoBackpropParallel will also work with nnet_to_update == NULL, and will compute the objf.
Both versions of the function will support it, but this version (that takes a vector) is currently the only one we need to do this with.
Definition at line 71 of file nnet-update-parallel.h.
References DoBackpropParallel().
Referenced by FastNnetCombiner::GetInitialModel().
|
static |
Definition at line 25 of file shrink-nnet.cc.
References VectorBase< Real >::ApplyExp(), ComputeNnetGradient(), VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, Nnet::NumComponents(), Nnet::ScaleComponents(), and Nnet::SetZero().
|
static |
Definition at line 61 of file combine-nnet-a.cc.
References AddDirection(), ComputeNnetGradient(), VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, Nnet::NumComponents(), and Nnet::SetZero().
Referenced by CombineNnets(), CombineNnetsA(), ComputeObjfAndGradient(), FastNnetCombiner::FastNnetCombiner(), and ShrinkNnet().
|
static |
Definition at line 124 of file combine-nnet.cc.
References CombineNnets(), ComputeNnetGradient(), ComputeObjfAndGradient(), VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_LOG, rnnlm::n, Nnet::NumComponents(), and Nnet::SetZero().
double DoBackprop | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | examples, | ||
Nnet * | nnet_to_update, | ||
double * | tot_accuracy = NULL |
||
) |
This function computes the objective function and either updates the model or adds to parameter gradients.
Returns the cross-entropy objective function summed over all samples (normalize this by dividing by TotalNnetTrainingWeight(examples)). It is mostly a wrapper for a class NnetUpdater that's defined in nnet-update.cc, but we don't want to expose that complexity at this level. All these examples will be treated as one minibatch. If tot_accuracy != NULL, it outputs to that pointer the total (weighted) accuracy.
Definition at line 265 of file nnet-update.cc.
References NnetUpdater::ComputeForMinibatch(), ComputeNnetObjf(), Nnet::Info(), and KALDI_LOG.
Referenced by ComputeNnetGradient(), DoBackpropSingleThreaded(), FisherComputationClass::operator()(), DoBackpropParallelClass::operator()(), and TrainNnetSimple().
double DoBackprop | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | examples, | ||
Matrix< BaseFloat > * | examples_formatted, | ||
Nnet * | nnet_to_update, | ||
double * | tot_accuracy = NULL |
||
) |
This version of DoBackprop allows you to separately call FormatNnetInput and provide the result to DoBackprop; this can be useful when using GPUs because the call to FormatNnetInput can be in a separate thread from the one that uses the GPU.
"examples_formatted" is really an input, but it's a pointer because internally we call Swap() on it, so we destroy its contents.
Definition at line 281 of file nnet-update.cc.
References NnetUpdater::ComputeForMinibatch(), ComputeNnetObjf(), Nnet::Info(), KALDI_LOG, and KALDI_WARN.
double DoBackpropParallel | ( | const Nnet & | nnet, |
int32 | minibatch_size, | ||
SequentialNnetExampleReader * | example_reader, | ||
double * | tot_weight, | ||
Nnet * | nnet_to_update | ||
) |
This function is similar to "DoBackprop" in nnet-update.h This function computes the objective function and either updates the model or computes parameter gradients.
It returns the cross-entropy objective function summed over all samples, weighted, and the total weight of the samples (typically the same as the #frames) into total_weight. It is mostly a wrapper for a class NnetUpdater that's defined in nnet-update.cc, but we don't want to expose that complexity at this level. Note: this function If &nnet == nnet_to_update, it assumes we're doing SGD and does something like Hogwild; otherwise it assumes we're computing a gradient and it sums up the gradients. The return value is the total log-prob summed over the #frames. It also outputs the #frames into "num_frames".
Definition at line 147 of file nnet-update-parallel.cc.
References ExamplesRepository::AcceptExamples(), DoBackpropSingleThreaded(), SequentialTableReader< Holder >::Done(), ExamplesRepository::ExamplesDone(), kaldi::g_num_threads, KALDI_LOG, SequentialTableReader< Holder >::Next(), and SequentialTableReader< Holder >::Value().
Referenced by ComputeNnetObjfParallel(), FastNnetCombiner::ComputeObjfAndGradient(), and main().
double DoBackpropParallel | ( | const Nnet & | nnet, |
int32 | minibatch_size, | ||
int32 | num_threads, | ||
const std::vector< NnetExample > & | examples, | ||
double * | num_frames, | ||
Nnet * | nnet_to_update | ||
) |
This version of DoBackpropParallel takes a vector of examples, and will typically be used to compute the exact gradient.
Definition at line 221 of file nnet-update-parallel.cc.
References ExamplesRepository::AcceptExamples(), DoBackpropSingleThreaded(), ExamplesRepository::ExamplesDone(), and KALDI_VLOG.
double kaldi::nnet2::DoBackpropSingleThreaded | ( | const Nnet & | nnet, |
int32 | minibatch_size, | ||
const std::vector< NnetExample > & | egs, | ||
double * | tot_weight, | ||
Nnet * | nnet_to_update | ||
) |
Definition at line 202 of file nnet-update-parallel.cc.
References DoBackprop(), rnnlm::i, and TotalNnetTrainingWeight().
Referenced by DoBackpropParallel().
void ExampleToPdfPost | ( | const TransitionModel & | tmodel, |
const std::vector< int32 > & | silence_phones, | ||
std::string | criterion, | ||
bool | drop_frames, | ||
bool | one_silence_class, | ||
const DiscriminativeNnetExample & | eg, | ||
Posterior * | post | ||
) |
Given a discriminative training example, this function works out posteriors at the pdf level (note: these are "discriminative-training posteriors" that may be positive or negative.
The denominator lattice "den_lat" in the example "eg" should already have had acoustic-rescoring done so that its acoustic probs are up to date, and any acoustic scaling should already have been applied.
"criterion" may be "mmi" or "mpfe" or "smbr". If criterion is "mmi", "drop_frames" means we don't include derivatives for frames where the numerator pdf is not in the denominator lattice.
if "one_silence_class" is true you can get a newer behavior for MPE/SMBR which will tend to reduce insertions.
"silence_phones" is a list of silence phones (this is only relevant for mpfe or smbr, if we want to treat silence specially).
Definition at line 838 of file nnet-example-functions.cc.
References fst::ConvertLattice(), kaldi::ConvertPosteriorToPdfs(), DiscriminativeNnetExample::den_lat, KALDI_ASSERT, kaldi::LatticeForwardBackwardMmi(), kaldi::LatticeForwardBackwardMpeVariants(), DiscriminativeNnetExample::num_ali, kaldi::ScalePosterior(), and DiscriminativeNnetExample::weight.
Referenced by SplitExampleStats::SplitExampleStats(), and UpdateHash().
void ExciseDiscriminativeExample | ( | const SplitDiscriminativeExampleConfig & | config, |
const TransitionModel & | tmodel, | ||
const DiscriminativeNnetExample & | eg, | ||
std::vector< DiscriminativeNnetExample > * | egs_out, | ||
SplitExampleStats * | stats_out | ||
) |
Remove unnecessary frames from discriminative training example.
The output egs_out will be of size zero or one (usually one) after being called.
Definition at line 775 of file nnet-example-functions.cc.
References DiscriminativeExampleSplitter::Excise().
Referenced by main(), and SplitExampleStats::SplitExampleStats().
|
static |
Definition at line 135 of file nnet-component.cc.
References kaldi::ExpectToken(), KALDI_ASSERT, KALDI_ERR, and kaldi::ReadToken().
Referenced by NonlinearComponent::Read(), MaxoutComponent::Read(), MaxpoolingComponent::Read(), PnormComponent::Read(), PowerComponent::Read(), ScaleComponent::Read(), AffineComponent::Read(), AffineComponentPreconditioned::Read(), AffineComponentPreconditionedOnline::Read(), SpliceComponent::Read(), SpliceMaxComponent::Read(), BlockAffineComponent::Read(), BlockAffineComponentPreconditioned::Read(), SumGroupComponent::Read(), PermuteComponent::Read(), DctComponent::Read(), FixedLinearComponent::Read(), FixedAffineComponent::Read(), FixedScaleComponent::Read(), FixedBiasComponent::Read(), DropoutComponent::Read(), AdditiveNoiseComponent::Read(), and Convolutional1dComponent::Read().
void FixNnet | ( | const NnetFixConfig & | config, |
Nnet * | nnet | ||
) |
Definition at line 31 of file nnet-fix.cc.
References AffineComponent::BiasParams(), count, NonlinearComponent::Count(), rnnlm::d, NonlinearComponent::DerivSum(), Nnet::GetComponent(), NonlinearComponent::InputDim(), KALDI_ASSERT, KALDI_LOG, KALDI_WARN, AffineComponent::LinearParams(), NnetFixConfig::max_average_deriv, NnetFixConfig::min_average_deriv, Nnet::NumComponents(), NnetFixConfig::parameter_factor, NnetFixConfig::relu_bias_change, and AffineComponent::SetParams().
Referenced by main(), and NnetFixConfig::Register().
void FormatNnetInput | ( | const Nnet & | nnet, |
const std::vector< NnetExample > & | data, | ||
Matrix< BaseFloat > * | mat | ||
) |
Takes the input to the nnet for a minibatch of examples, and formats as a single matrix.
data.size() must be > 0. Note: you will probably want to copy this to CuMatrix after you call this function. The num-rows of the output will, at exit, equal (1 + nnet.LeftContext() + nnet.RightContext()) * data.size(). The nnet is only needed so we can call LeftContext(), RightContext() and InputDim() on it.
Definition at line 207 of file nnet-update.cc.
References MatrixBase< Real >::CopyFromMat(), MatrixBase< Real >::CopyRowsFromVec(), Nnet::InputDim(), KALDI_ASSERT, kaldi::kUndefined, Nnet::LeftContext(), Matrix< Real >::Resize(), and Nnet::RightContext().
Referenced by NnetUpdater::FormatInput(), and NnetExampleBackgroundReader::ReadExamples().
This function generates a random neural net, for testing purposes.
It will contain a random number of SigmoidComponent, AffineComponent and SpliceComponent, followed by a final AffineComponent and SoftmaxComponent. The parameters will all be randomly initialized.
Definition at line 772 of file nnet-nnet.cc.
References rnnlm::i, Nnet::Init(), AffineComponent::Init(), SpliceComponent::Init(), and Nnet::Nnet().
Referenced by UnitTestAmNnet(), UnitTestNnet(), UnitTestNnetCompute(), UnitTestNnetComputeChunked(), and UnitTestNnetDecodable().
int32 GetCount | ( | double | expected_count | ) |
Definition at line 31 of file nnet-copy-egs-discriminative.cc.
References KALDI_ASSERT, and kaldi::WithProb().
Referenced by main(), and ProcessFile().
|
static |
Returns an integer saying which model to use: either 0 ...
num-models - 1 for the best individual model, or (#models) for the average of all of them.
Definition at line 49 of file combine-nnet.cc.
References CombineNnets(), ComputeNnetObjf(), KALDI_ASSERT, KALDI_LOG, rnnlm::n, and VectorBase< Real >::Set().
Referenced by FastNnetCombiner::FastNnetCombiner(), FastNnetCombiner::GetInitialParams(), and GetInitialScaleParams().
|
static |
Definition at line 91 of file combine-nnet.cc.
References GetInitialModel(), NnetCombineConfig::initial_model, KALDI_ASSERT, KALDI_LOG, Vector< Real >::Resize(), and VectorBase< Real >::Set().
Referenced by CombineNnets().
void GetNnetStats | ( | const NnetStatsConfig & | config, |
const Nnet & | nnet, | ||
std::vector< NnetStats > * | stats | ||
) |
Definition at line 99 of file nnet-stats.cc.
References NnetStatsConfig::bucket_width, Nnet::GetComponent(), KALDI_ASSERT, NnetStats::NnetStats(), and Nnet::NumComponents().
|
static |
Definition at line 31 of file combine-nnet-a.cc.
References Nnet::AddNnet(), KALDI_ASSERT, rnnlm::n, kaldi::nnet3::NumUpdatableComponents(), Nnet::ScaleComponents(), and VectorBase< Real >::Set().
Referenced by CombineNnetsA().
|
static |
This function makes sure the neural net ends with a SumGroupComponent.
If it doesn't, it adds one (with a single mixture/matrix corresponding to each output element.) [Before doing so, it makes sure that the last layer is a SoftmaxLayer, which is what we expect. You can remove this check if there is some use-case that makes sense where the type of the previous layer is different.
Definition at line 37 of file mixup-nnet.cc.
References Nnet::Append(), Nnet::GetComponent(), KALDI_ASSERT, KALDI_ERR, KALDI_LOG, Nnet::NumComponents(), Component::OutputDim(), and Component::Type().
Referenced by MixupNnet().
bool kaldi::nnet2::HasSimpleLabels | ( | const NnetExample & | eg, |
std::vector< int32 > * | simple_labels | ||
) |
Definition at line 32 of file nnet-example.cc.
References NnetExample::labels.
Referenced by NnetExample::Write().
If "nnet" has exactly one softmax layer, this function will return its index; otherwise it will return -1.
Definition at line 27 of file nnet-functions.cc.
References Nnet::GetComponent(), and Nnet::NumComponents().
Referenced by main().
Inserts the components of one neural network into a particular place in the other one.
This is useful for adding hidden layers to a neural net. Inserts the components of "src_nnet" before component index c of "dest_nnet".
Definition at line 39 of file nnet-functions.cc.
References Component::Copy(), Nnet::GetComponent(), Nnet::Init(), KALDI_ASSERT, and Nnet::NumComponents().
Referenced by main().
BaseFloat kaldi::nnet2::KlDivergence | ( | const Vector< BaseFloat > & | p, |
const Vector< BaseFloat > & | q | ||
) |
Definition at line 31 of file nnet-adjust-priors.cc.
References VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, KALDI_WARN, kaldi::Log(), and VectorBase< Real >::Sum().
Referenced by PrintPriorDiagnostics().
bool LatticeToDiscriminativeExample | ( | const std::vector< int32 > & | alignment, |
const Matrix< BaseFloat > & | feats, | ||
const CompactLattice & | clat, | ||
BaseFloat | weight, | ||
int32 | left_context, | ||
int32 | right_context, | ||
DiscriminativeNnetExample * | eg | ||
) |
Converts lattice to discriminative training example.
returns true on success, false on failure such as mismatched input (will also warn in this case).
Definition at line 27 of file nnet-example-functions.cc.
References DiscriminativeNnetExample::Check(), kaldi::CompactLatticeStateTimes(), DiscriminativeNnetExample::den_lat, DiscriminativeNnetExample::input_frames, KALDI_ASSERT, KALDI_WARN, DiscriminativeNnetExample::left_context, DiscriminativeNnetExample::num_ali, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Range(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), and DiscriminativeNnetExample::weight.
Referenced by main(), and SplitExampleStats::SplitExampleStats().
void LimitRankParallel | ( | const NnetLimitRankOpts & | opts, |
Nnet * | nnet | ||
) |
This function limits the rank of each affine transform in the neural net, by zeroing out the smallest singular values.
The number of singular values to zero out is determined on a layer by layer basis, using "parameter_proportion" to set the proportion of parameters to remove.
Definition at line 99 of file nnet-limit-rank.cc.
References Nnet::GetComponent(), NnetLimitRankOpts::num_threads, TaskSequencerConfig::num_threads, Nnet::NumComponents(), and TaskSequencer< C >::Run().
Referenced by NnetLimitRankOpts::Register().
Definition at line 27 of file train-nnet-ensemble.cc.
References Int32Pair::first, and Int32Pair::second.
Referenced by NnetEnsembleTrainer::TrainOneMinibatch().
void MixupNnet | ( | const NnetMixupConfig & | mixup_config, |
Nnet * | nnet | ||
) |
This function works as follows.
This function does something similar to Gaussian mixture splitting for GMMs, except applied to the output layer of the neural network.
We first make sure the neural net has the correct topology, so its last component is a SumGroupComponent.
We then get the counts for each matrix in the SumGroupComponent (these will either correspond to leaves in the decision tree, or level-1 leaves, if we have a 2-level-tree system). We work out the total count for each of these matrices, by getting the count from the SoftmaxComponent.
We then increase, if necessary, the dimensions that the SumGroupComponent sums over increase the dimension of the SoftmaxComponent if necessary, and duplicate and then perturb the relevant rows of the AffineComponent.
We create additional outputs, which will be summed over using a SumGroupComponent.
Definition at line 86 of file mixup-nnet.cc.
References Nnet::Check(), GiveNnetCorrectTopology(), NnetMixupConfig::min_count, SoftmaxComponent::MixUp(), NnetMixupConfig::num_mixtures, NnetMixupConfig::perturb_stddev, and NnetMixupConfig::power.
Referenced by main(), and NnetMixupConfig::Register().
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.
an utterance). If pad_input==true we'll pad the input with enough frames of context, and the output will be a matrix of #frames by the output-dim of the network, typically representing state-level posteriors. If pad_input==false we won't do this and the output will have a lower #frames than the input; we lose nnet.LeftContext() at the left and nnet.RightContext() at the output.
Definition at line 160 of file nnet-compute.cc.
References CuMatrixBase< Real >::CopyFromMat(), NnetComputer::GetOutput(), and NnetComputer::Propagate().
Referenced by NnetComputation::Clear(), CachingOptimizingCompiler::CompileNoShortcut(), CachingOptimizingCompiler::CompileViaShortcut(), DecodableAmNnetParallel::Compute(), DecodableNnet2Online::ComputeForFrame(), DecodableAmNnet::DecodableAmNnet(), main(), ComputationCache::Read(), UnitTestNnetCompute(), and UnitTestNnetComputeChunked().
void NnetComputationChunked | ( | const Nnet & | nnet, |
const CuMatrixBase< BaseFloat > & | input, | ||
int32 | chunk_size, | ||
CuMatrixBase< BaseFloat > * | output | ||
) |
Does the basic neural net computation, on a sequence of data (e.g.
an utterance). This variant of NnetComputation chunks the input according to chunk_size and does the posterior computation chunk by chunk. This allows the computation to be performed on the GPU when the input matrix is very large. Input is padded with enough frames of context so that the output will be a matrix with input.NumRows().
Definition at line 169 of file nnet-compute.cc.
References CuMatrixBase< Real >::CopyFromMat(), NnetComputer::GetOutput(), rnnlm::i, Nnet::LeftContext(), CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), NnetComputer::Propagate(), CuMatrixBase< Real >::Range(), CuMatrix< Real >::Resize(), Nnet::RightContext(), and CuMatrixBase< Real >::Row().
Referenced by main(), and UnitTestNnetComputeChunked().
void NnetDiscriminativeUpdate | ( | const AmNnet & | am_nnet, |
const TransitionModel & | tmodel, | ||
const NnetDiscriminativeUpdateOptions & | opts, | ||
const DiscriminativeNnetExample & | eg, | ||
Nnet * | nnet_to_update, | ||
NnetDiscriminativeStats * | stats | ||
) |
Does the neural net computation, lattice forward-backward, and backprop, for either the MMI, MPFE or SMBR objective functions.
If nnet_to_update == &(am_nnet.GetNnet()), then this does stochastic gradient descent, otherwise (assuming you have called SetZero(true) on *nnet_to_update) it will compute the gradient on this data. If nnet_to_update_ == NULL, no backpropagation is done.
Note: we ignore any existing acoustic score in the lattice of "eg".
For display purposes you should normalize the sum of this return value by dividing by the sum over the examples, of the number of frames (num_ali.size()) times the weight.
Something you need to be careful with is that the occupation counts and the derivative are, following tradition, missing a factor equal to the acoustic scale. So you need to multiply them by that scale if you plan to do something like L-BFGS in which you look at both the derivatives and function values.
Definition at line 365 of file nnet-compute-discriminative.cc.
References NnetDiscriminativeUpdater::Update().
Referenced by main(), NnetDiscriminativeStats::NnetDiscriminativeStats(), and DiscTrainParallelClass::operator()().
void NnetDiscriminativeUpdateParallel | ( | const AmNnet & | am_nnet, |
const TransitionModel & | tmodel, | ||
const NnetDiscriminativeUpdateOptions & | opts, | ||
int32 | num_threads, | ||
SequentialDiscriminativeNnetExampleReader * | example_reader, | ||
Nnet * | nnet_to_update, | ||
NnetDiscriminativeStats * | stats | ||
) |
Definition at line 189 of file nnet-compute-discriminative-parallel.cc.
References DiscriminativeExamplesRepository::AcceptExample(), NnetDiscriminativeUpdateOptions::criterion, SequentialTableReader< Holder >::Done(), DiscriminativeExamplesRepository::ExamplesDone(), AmNnet::GetNnet(), SequentialTableReader< Holder >::Next(), NnetDiscriminativeStats::Print(), and SequentialTableReader< Holder >::Value().
Referenced by main().
BaseFloat kaldi::nnet2::NnetGradientComputation | ( | const Nnet & | nnet, |
const MatrixBase< BaseFloat > & | input, | ||
bool | pad_input, | ||
BaseFloat | utterance_weight, | ||
const std::vector< int32 > & | labels, | ||
Nnet * | nnet_to_update | ||
) |
Does the neural net computation and backprop, given input and labels.
Note: if pad_input==true the number of rows of input should be the same as the number of labels, and if false, you should omit nnet.LeftContext() labels on the left and nnet.RightContext() on the right. If nnet_to_update == &nnet, then this does stochastic gradient descent, otherwise (assuming you have called SetZero(true) on *nnet_to_update) it will compute the gradient on this data. Returns the total objective function summed over the frames, times the utterance weight.
BaseFloat kaldi::nnet2::NnetGradientComputation | ( | const Nnet & | nnet, |
const CuMatrixBase< BaseFloat > & | input, | ||
bool | pad_input, | ||
const Posterior & | pdf_post, | ||
Nnet * | nnet_to_update | ||
) |
Definition at line 208 of file nnet-compute.cc.
References NnetComputer::Backprop(), NnetComputer::ComputeLastLayerDeriv(), and NnetComputer::Propagate().
Functions used in Init routines.
Suppose name=="foo", if "string" has a field like foo=12, this function will set "param" to 12 and remove that element from "string". It returns true if the parameter was read.
Definition at line 153 of file nnet-component.cc.
References kaldi::ConvertStringToInteger(), rnnlm::i, rnnlm::j, KALDI_ERR, and kaldi::SplitStringToVector().
Referenced by NonlinearComponent::InitFromString(), MaxoutComponent::InitFromString(), MaxpoolingComponent::InitFromString(), PnormComponent::InitFromString(), PowerComponent::InitFromString(), ScaleComponent::InitFromString(), AffineComponent::InitFromString(), AffineComponentPreconditioned::InitFromString(), AffineComponentPreconditionedOnline::InitFromString(), SpliceComponent::InitFromString(), SpliceMaxComponent::InitFromString(), BlockAffineComponent::InitFromString(), BlockAffineComponentPreconditioned::InitFromString(), SumGroupComponent::InitFromString(), PermuteComponent::InitFromString(), DctComponent::InitFromString(), FixedLinearComponent::InitFromString(), FixedAffineComponent::InitFromString(), FixedScaleComponent::InitFromString(), FixedBiasComponent::InitFromString(), DropoutComponent::InitFromString(), AdditiveNoiseComponent::InitFromString(), Convolutional1dComponent::InitFromString(), and UnitTestParsing().
This version is for parameters of type bool, which can appear as any string beginning with f, F, t or T.
Definition at line 179 of file nnet-component.cc.
References rnnlm::i, rnnlm::j, KALDI_ERR, and kaldi::SplitStringToVector().
This version is for parameters of type BaseFloat.
Definition at line 210 of file nnet-component.cc.
References kaldi::ConvertStringToReal(), rnnlm::i, rnnlm::j, KALDI_ERR, and kaldi::SplitStringToVector().
bool kaldi::nnet2::ParseFromString | ( | const std::string & | name, |
std::string * | string, | ||
std::string * | param | ||
) |
Definition at line 236 of file nnet-component.cc.
References rnnlm::i, rnnlm::j, and kaldi::SplitStringToVector().
bool ParseFromString | ( | const std::string & | name, |
std::string * | string, | ||
std::vector< int32 > * | param | ||
) |
This version is for parameters of type std::vector<int32>; it expects them as a colon-separated list, without spaces.
Definition at line 262 of file nnet-component.cc.
References rnnlm::i, rnnlm::j, KALDI_ERR, kaldi::SplitStringToIntegers(), and kaldi::SplitStringToVector().
void PreconditionDirections | ( | const CuMatrixBase< BaseFloat > & | R, |
double | lambda, | ||
CuMatrixBase< BaseFloat > * | P | ||
) |
See below for comment.
The function PreconditionDirections views the input R as a set of directions or gradients, each row r_i being one of the directions.
For each i it constructs a preconditioning matrix G_i formed from the *other* i's, using the formula:
G_i = ( I + (1/(N-1)) {j i} r_j r_j^T)^{-1},
where N is the number of rows in R. This can be seen as a kind of estimated Fisher matrix that has been smoothed with the identity to make it invertible. We recommend that you set using: = /(N D) trace(R^T, R) for some small such as = 0.1. However, we leave this to the caller because there are reasons relating to unbiased-ness of the resulting stochastic gradient descent, why you might want to set using "other" data, e.g. a previous minibatch.
The output of this function is a matrix P, each row p_i of which is related to r_i by: p_i = G_i r_i Here, p_i is preconditioned by an estimated Fisher matrix in such a way that it's suitable to be used as an update direction.
Definition at line 26 of file nnet-precondition.cc.
References CuVectorBase< Real >::AddDiagMatMat(), CuMatrixBase< Real >::AddMatMat(), CuMatrixBase< Real >::AddToDiag(), CuMatrixBase< Real >::CopyFromMat(), CuMatrixBase< Real >::CopyLowerToUpper(), kaldi::GetVerboseLevel(), KALDI_ASSERT, KALDI_ERR, KALDI_WARN, kaldi::kNoTrans, kaldi::kTakeLower, kaldi::kTrans, kaldi::kUndefined, CuMatrixBase< Real >::MulRowsVec(), rnnlm::n, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), SpMatrix< Real >::PrintEigs(), kaldi::Rand(), kaldi::SameDim(), CuVectorBase< Real >::Scale(), CuMatrixBase< Real >::SymAddMat2(), CuMatrixBase< Real >::SymInvertPosDef(), and kaldi::VecVec().
Referenced by PreconditionDirectionsAlpha(), PreconditionDirectionsAlphaRescaled(), and UnitTestPreconditionDirections().
void PreconditionDirectionsAlpha | ( | const CuMatrixBase< BaseFloat > & | R, |
double | alpha, | ||
CuMatrixBase< BaseFloat > * | P | ||
) |
This wrapper for PreconditionDirections computes lambda using = /(N D) trace(R^T, R), and calls PreconditionDirections.
Definition at line 114 of file nnet-precondition.cc.
References KALDI_ASSERT, KALDI_WARN, kaldi::kTrans, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), PreconditionDirections(), and kaldi::TraceMatMat().
void PreconditionDirectionsAlphaRescaled | ( | const CuMatrixBase< BaseFloat > & | R, |
double | alpha, | ||
CuMatrixBase< BaseFloat > * | P | ||
) |
This wrapper for PreconditionDirections computes lambda using = /(N D) trace(R^T, R), and calls PreconditionDirections.
It then rescales *P so that its 2-norm is the same as that of R.
Definition at line 138 of file nnet-precondition.cc.
References CuMatrixBase< Real >::CopyFromMat(), KALDI_ASSERT, KALDI_WARN, kaldi::kTrans, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), PreconditionDirections(), CuMatrixBase< Real >::Scale(), and kaldi::TraceMatMat().
Referenced by AffineComponentPreconditioned::Update(), and BlockAffineComponentPreconditioned::Update().
void kaldi::nnet2::PrintPriorDiagnostics | ( | const Vector< BaseFloat > & | old_priors, |
const Vector< BaseFloat > & | new_priors | ||
) |
Definition at line 48 of file nnet-adjust-priors.cc.
References VectorBase< Real >::AddVec(), VectorBase< Real >::ApplyAbs(), VectorBase< Real >::Dim(), KALDI_LOG, KlDivergence(), and VectorBase< Real >::Max().
Referenced by main().
|
static |
Definition at line 32 of file nnet-get-egs.cc.
References NnetExample::input_frames, rnnlm::j, KALDI_ASSERT, NnetExample::labels, NnetExample::left_context, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Row(), NnetExample::spk_info, and TableWriter< Holder >::Write().
Referenced by main().
|
static |
Definition at line 45 of file nnet-get-weighted-egs.cc.
References VectorBase< Real >::CopyFromVec(), count, GetCount(), rnnlm::i, NnetExample::input_frames, rnnlm::j, KALDI_ASSERT, NnetExample::labels, NnetExample::left_context, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::Row(), NnetExample::spk_info, and TableWriter< Holder >::Write().
Removes the last "num_to_remove" components and adds the components from "src_nnet".
Definition at line 58 of file nnet-functions.cc.
References Component::Copy(), Nnet::GetComponent(), Nnet::Init(), KALDI_ASSERT, and Nnet::NumComponents().
Referenced by main().
void RescaleNnet | ( | const NnetRescaleConfig & | rescale_config, |
const std::vector< NnetExample > & | examples, | ||
Nnet * | nnet | ||
) |
Definition at line 218 of file rescale-nnet.cc.
References NnetRescaler::Rescale().
Referenced by NnetRescaleConfig::Register().
Definition at line 29 of file nnet-modify-learning-rates.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and AffineComponentPreconditioned::SetMaxChange().
Referenced by main().
void kaldi::nnet2::SetPriors | ( | const TransitionModel & | tmodel, |
const Vector< double > & | transition_accs, | ||
double | prior_floor, | ||
AmNnet * | am_nnet | ||
) |
Definition at line 28 of file nnet-train-transitions.cc.
References VectorBase< Real >::Dim(), KALDI_ASSERT, AmNnet::NumPdfs(), TransitionModel::NumPdfs(), AmNnet::SetPriors(), and TransitionModel::TransitionIdToPdf().
Referenced by main().
void ShrinkNnet | ( | const NnetShrinkConfig & | shrink_config, |
const std::vector< NnetExample > & | validation_set, | ||
Nnet * | nnet | ||
) |
Definition at line 66 of file shrink-nnet.cc.
References VectorBase< Real >::ApplyExp(), ComputeObjfAndGradient(), OptimizeLbfgs< Real >::DoStep(), LbfgsOptions::first_step_length, OptimizeLbfgs< Real >::GetProposedValue(), OptimizeLbfgs< Real >::GetValue(), rnnlm::i, NnetShrinkConfig::initial_step, KALDI_ASSERT, KALDI_LOG, KALDI_VLOG, LbfgsOptions::m, LbfgsOptions::minimize, NnetShrinkConfig::num_bfgs_iters, Nnet::NumUpdatableComponents(), and Nnet::ScaleComponents().
Referenced by NnetShrinkConfig::Register().
void SolvePackingProblem | ( | BaseFloat | max_cost, |
const std::vector< BaseFloat > & | costs, | ||
std::vector< std::vector< size_t > > * | groups | ||
) |
This function solves the "packing problem" using the "first fit" algorithm.
It groups together the indices 0 through sizes.size() - 1, such that the sum of cost within each group does not exceed max_lcost. [However, if there are single examples that exceed max_cost, it puts them in their own bin]. The algorithm is not particularly efficient– it's more n^2 than n log(n) which it should be.
Definition at line 867 of file nnet-example-functions.cc.
References rnnlm::i, and rnnlm::j.
Referenced by CombineDiscriminativeExamples(), SplitExampleStats::SplitExampleStats(), and UnitTestSolvePackingProblem().
void SplitDiscriminativeExample | ( | const SplitDiscriminativeExampleConfig & | config, |
const TransitionModel & | tmodel, | ||
const DiscriminativeNnetExample & | eg, | ||
std::vector< DiscriminativeNnetExample > * | egs_out, | ||
SplitExampleStats * | stats_out | ||
) |
Split a "discriminative example" into multiple pieces, splitting where the lattice has "pinch points".
Definition at line 764 of file nnet-example-functions.cc.
References DiscriminativeExampleSplitter::Split().
Referenced by main(), and SplitExampleStats::SplitExampleStats().
BaseFloat TotalNnetTrainingWeight | ( | const std::vector< NnetExample > & | egs | ) |
Returns the total weight summed over all the examples...
just a simple utility function.
Definition at line 248 of file nnet-update.cc.
References rnnlm::i, and rnnlm::j.
Referenced by DoBackpropSingleThreaded(), main(), DoBackpropParallelClass::operator()(), and NnetExampleBackgroundReader::ReadExamples().
int64 TrainNnetSimple | ( | const NnetSimpleTrainerConfig & | config, |
Nnet * | nnet, | ||
SequentialNnetExampleReader * | reader, | ||
double * | tot_weight = NULL , |
||
double * | tot_logprob = NULL |
||
) |
Train on all the examples it can read from the reader.
This does training in a single thread, but it uses a separate thread to read in the examples and format the input data on the CPU; this saves us time when using GPUs. Returns the number of examples processed. Outputs to tot_weight and tot_logprob_per_frame, if non-NULL, the total weight of the examples (typically equal to the number of examples) and the total logprob objective function.
Definition at line 147 of file train-nnet.cc.
References DoBackprop(), NnetExampleBackgroundReader::GetNextMinibatch(), rnnlm::i, KALDI_ASSERT, KALDI_LOG, KALDI_WARN, NnetSimpleTrainerConfig::minibatch_size, and NnetSimpleTrainerConfig::minibatches_per_phase.
Referenced by main(), and NnetSimpleTrainerConfig::Register().
void kaldi::nnet2::UnitTestAdditiveNoiseComponent | ( | ) |
Definition at line 434 of file nnet-component-test.cc.
References rnnlm::i, AdditiveNoiseComponent::InitFromString(), KALDI_ERR, KALDI_WARN, kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestAffineComponent | ( | ) |
Definition at line 337 of file nnet-component-test.cc.
References AffineComponent::Init(), AffineComponent::InitFromString(), kaldi::Rand(), MatrixBase< Real >::Scale(), MatrixBase< Real >::SetRandn(), kaldi::Sleep(), UnitTestGenericComponentInternal(), and kaldi::WriteKaldiObject().
Referenced by main().
void kaldi::nnet2::UnitTestAffineComponentPreconditioned | ( | ) |
Definition at line 478 of file nnet-component-test.cc.
References AffineComponentPreconditioned::Init(), AffineComponentPreconditioned::InitFromString(), kaldi::Rand(), MatrixBase< Real >::Scale(), MatrixBase< Real >::SetRandn(), kaldi::Sleep(), UnitTestGenericComponentInternal(), and kaldi::WriteKaldiObject().
Referenced by main().
void kaldi::nnet2::UnitTestAffineComponentPreconditionedOnline | ( | ) |
Definition at line 509 of file nnet-component-test.cc.
References AffineComponentPreconditionedOnline::Init(), AffineComponentPreconditionedOnline::InitFromString(), kaldi::Rand(), MatrixBase< Real >::Scale(), MatrixBase< Real >::SetRandn(), kaldi::Sleep(), UnitTestGenericComponentInternal(), and kaldi::WriteKaldiObject().
Referenced by main().
void kaldi::nnet2::UnitTestAmNnet | ( | ) |
Definition at line 29 of file am-nnet-test.cc.
References VectorBase< Real >::ApplyExp(), kaldi::GenRandContextDependencyLarge(), GenRandomNnet(), kaldi::GetDefaultTopology(), rnnlm::i, KALDI_ASSERT, TransitionModel::NumPdfs(), AmNnet::Read(), VectorBase< Real >::Scale(), AmNnet::SetPriors(), VectorBase< Real >::SetRandn(), VectorBase< Real >::Sum(), and AmNnet::Write().
Referenced by main().
void kaldi::nnet2::UnitTestBlockAffineComponent | ( | ) |
Definition at line 544 of file nnet-component-test.cc.
References BlockAffineComponent::Init(), BlockAffineComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestBlockAffineComponentPreconditioned | ( | ) |
Definition at line 565 of file nnet-component-test.cc.
References BlockAffineComponentPreconditioned::Init(), BlockAffineComponentPreconditioned::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestConvolutional1dComponent | ( | ) |
Definition at line 365 of file nnet-component-test.cc.
References Convolutional1dComponent::Init(), Convolutional1dComponent::InitFromString(), kaldi::Rand(), MatrixBase< Real >::Scale(), MatrixBase< Real >::SetRandn(), kaldi::Sleep(), UnitTestGenericComponentInternal(), and kaldi::WriteKaldiObject().
Referenced by main().
void kaldi::nnet2::UnitTestDctComponent | ( | ) |
Definition at line 607 of file nnet-component-test.cc.
References DctComponent::Init(), DctComponent::InitFromString(), rnnlm::n, kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestDropoutComponent | ( | ) |
Definition at line 407 of file nnet-component-test.cc.
References rnnlm::i, DropoutComponent::InitFromString(), KALDI_ERR, KALDI_WARN, kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestFixedAffineComponent | ( | ) |
Definition at line 655 of file nnet-component-test.cc.
References FixedAffineComponent::Init(), rnnlm::n, kaldi::Rand(), CuMatrixBase< Real >::SetRandn(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestFixedBiasComponent | ( | ) |
Definition at line 677 of file nnet-component-test.cc.
References FixedBiasComponent::Init(), kaldi::Rand(), CuVectorBase< Real >::SetRandn(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestFixedLinearComponent | ( | ) |
Definition at line 643 of file nnet-component-test.cc.
References FixedLinearComponent::Init(), rnnlm::n, kaldi::Rand(), CuMatrixBase< Real >::SetRandn(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestFixedScaleComponent | ( | ) |
Definition at line 666 of file nnet-component-test.cc.
References FixedScaleComponent::Init(), kaldi::Rand(), CuVectorBase< Real >::SetRandn(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestGenericComponent | ( | std::string | extra_str = "" | ) |
Definition at line 244 of file nnet-component-test.cc.
References kaldi::Rand(), and UnitTestGenericComponentInternal().
void kaldi::nnet2::UnitTestGenericComponentInternal | ( | const Component & | component, |
const ChunkInfo | in_info, | ||
const ChunkInfo | out_info | ||
) |
Definition at line 28 of file nnet-component-test.cc.
References CuVectorBase< Real >::AddMatVec(), Component::Backprop(), Component::BackpropNeedsInput(), Component::BackpropNeedsOutput(), Component::Copy(), UpdatableComponent::DotProduct(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, KALDI_WARN, kaldi::kNoTrans, kaldi::kTrans, ChunkInfo::NumCols(), ChunkInfo::NumRows(), UpdatableComponent::PerturbParams(), Component::Propagate(), kaldi::Rand(), Component::ReadNew(), RandomComponent::ResetGenerator(), CuMatrixBase< Real >::Row(), CuVectorBase< Real >::SetRandn(), CuMatrixBase< Real >::SetRandn(), Output::Stream(), Input::Stream(), kaldi::TraceMatMat(), and Component::Write().
Referenced by UnitTestAdditiveNoiseComponent(), UnitTestAffineComponent(), UnitTestAffineComponentPreconditioned(), UnitTestAffineComponentPreconditionedOnline(), UnitTestBlockAffineComponent(), UnitTestBlockAffineComponentPreconditioned(), UnitTestConvolutional1dComponent(), UnitTestDctComponent(), UnitTestDropoutComponent(), UnitTestFixedAffineComponent(), UnitTestFixedBiasComponent(), UnitTestFixedLinearComponent(), UnitTestFixedScaleComponent(), UnitTestGenericComponent(), UnitTestGenericComponentInternal(), UnitTestMaxoutComponent(), UnitTestMaxpoolingComponent(), UnitTestPnormComponent(), UnitTestScaleComponent(), UnitTestSigmoidComponent(), UnitTestSpliceComponent(), and UnitTestSumGroupComponent().
void kaldi::nnet2::UnitTestGenericComponentInternal | ( | const Component & | component | ) |
Definition at line 210 of file nnet-component-test.cc.
References Component::Info(), Component::InputDim(), KALDI_LOG, Component::OutputDim(), kaldi::Rand(), and UnitTestGenericComponentInternal().
void kaldi::nnet2::UnitTestMaxoutComponent | ( | ) |
Definition at line 263 of file nnet-component-test.cc.
References rnnlm::i, MaxoutComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestMaxpoolingComponent | ( | ) |
Definition at line 310 of file nnet-component-test.cc.
References rnnlm::i, MaxpoolingComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestNnet | ( | ) |
Definition at line 26 of file nnet-nnet-test.cc.
References GenRandomNnet(), KALDI_ASSERT, Nnet::Read(), and Nnet::Write().
Referenced by main().
void kaldi::nnet2::UnitTestNnetCompute | ( | ) |
Definition at line 29 of file nnet-compute-test.cc.
References kaldi::AssertEqual(), NnetOnlineComputer::Compute(), NnetOnlineComputer::Flush(), GenRandomNnet(), rnnlm::i, Nnet::Info(), KALDI_LOG, Nnet::LeftContext(), NnetComputation(), CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), Nnet::RightContext(), and CuMatrixBase< Real >::SetRandn().
Referenced by main().
void kaldi::nnet2::UnitTestNnetComputeChunked | ( | ) |
Definition at line 83 of file nnet-compute-test.cc.
References kaldi::AssertEqual(), GenRandomNnet(), rnnlm::i, Nnet::Info(), KALDI_LOG, Nnet::LeftContext(), NnetComputation(), NnetComputationChunked(), MatrixBase< Real >::NumRows(), Nnet::RightContext(), and CuMatrixBase< Real >::SetRandn().
Referenced by main().
void kaldi::nnet2::UnitTestNnetDecodable | ( | ) |
Definition at line 31 of file online-nnet2-decodable-test.cc.
References DecodableNnet2OnlineOptions::acoustic_scale, VectorBase< Real >::ApplyExp(), kaldi::ApproxEqual(), kaldi::GenRandContextDependencyLarge(), GenRandomNnet(), kaldi::GetDefaultTopology(), rnnlm::i, KALDI_ASSERT, DecodableNnet2Online::LogLikelihood(), DecodableAmNnet::LogLikelihood(), DecodableNnet2OnlineOptions::max_nnet_batch_size, DecodableNnet2Online::NumFramesReady(), DecodableAmNnet::NumFramesReady(), TransitionModel::NumPdfs(), TransitionModel::NumTransitionIds(), DecodableNnet2OnlineOptions::pad_input, VectorBase< Real >::Scale(), AmNnet::SetPriors(), VectorBase< Real >::SetRandn(), MatrixBase< Real >::SetRandn(), and VectorBase< Real >::Sum().
Referenced by main().
void kaldi::nnet2::UnitTestParsing | ( | ) |
Definition at line 690 of file nnet-component-test.cc.
References rnnlm::i, KALDI_ASSERT, and ParseFromString().
Referenced by main().
void kaldi::nnet2::UnitTestPnormComponent | ( | ) |
Definition at line 286 of file nnet-component-test.cc.
References rnnlm::i, KALDI_ERR, KALDI_WARN, kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestPreconditionDirections | ( | ) |
Definition at line 26 of file nnet-precondition-test.cc.
References CuSpMatrix< Real >::AddMat2(), CuVectorBase< Real >::AddSpVec(), CuSpMatrix< Real >::AddVec2(), CuVectorBase< Real >::ApproxEqual(), CuSpMatrix< Real >::Invert(), KALDI_ASSERT, kaldi::kTrans, rnnlm::n, PreconditionDirections(), kaldi::Rand(), CuPackedMatrix< Real >::ScaleDiag(), CuMatrixBase< Real >::SetRandn(), and CuPackedMatrix< Real >::SetUnit().
Referenced by main().
void kaldi::nnet2::UnitTestPreconditionDirectionsOnline | ( | ) |
Definition at line 262 of file nnet-precondition-online-test.cc.
References CuVectorBase< Real >::AddDiagMatMat(), MatrixBase< Real >::AddVecVec(), kaldi::AssertEqual(), KALDI_ASSERT, kaldi::kNoTrans, kaldi::kTrans, CuMatrixBase< Real >::NumRows(), OnlinePreconditionerSimple::PreconditionDirections(), OnlinePreconditioner::PreconditionDirections(), kaldi::Rand(), kaldi::RandInt(), VectorBase< Real >::Scale(), MatrixBase< Real >::Set(), VectorBase< Real >::SetRandn(), MatrixBase< Real >::SetRandn(), OnlinePreconditionerSimple::SetRank(), OnlinePreconditioner::SetRank(), kaldi::TraceMatMat(), and OnlinePreconditioner::TurnOnDebug().
Referenced by main().
void kaldi::nnet2::UnitTestScaleComponent | ( | ) |
Definition at line 461 of file nnet-component-test.cc.
References ScaleComponent::Init(), ScaleComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestSigmoidComponent | ( | ) |
Definition at line 227 of file nnet-component-test.cc.
References NonlinearComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestSolvePackingProblem | ( | ) |
Definition at line 29 of file nnet-example-functions-test.cc.
References rnnlm::i, rnnlm::j, KALDI_ASSERT, kaldi::Rand(), SolvePackingProblem(), and kaldi::SortAndUniq().
Referenced by main().
void kaldi::nnet2::UnitTestSpliceComponent | ( | ) |
Definition at line 741 of file nnet-component-test.cc.
References rnnlm::i, SpliceComponent::Init(), KALDI_LOG, kaldi::RandInt(), and UnitTestGenericComponentInternal().
Referenced by main().
void kaldi::nnet2::UnitTestSumGroupComponent | ( | ) |
Definition at line 587 of file nnet-component-test.cc.
References rnnlm::i, SumGroupComponent::Init(), SumGroupComponent::InitFromString(), kaldi::Rand(), and UnitTestGenericComponentInternal().
Referenced by main().
void UpdateHash | ( | const TransitionModel & | tmodel, |
const DiscriminativeNnetExample & | eg, | ||
std::string | criterion, | ||
bool | drop_frames, | ||
bool | one_silence_class, | ||
Matrix< double > * | hash, | ||
double * | num_weight, | ||
double * | den_weight, | ||
double * | tot_t | ||
) |
This function is used in code that tests the functionality that we provide here, about splitting and excising nnet examples.
It adds to a "hash function" that is a function of a set of examples; the hash function is of dimension (number of pdf-ids x features dimension). The hash function consists of the (denominator - numerator) posteriors over pdf-ids, times the average over the context-window (left-context on the left, right-context on the right), of the features. This is useful because the various manipulations we do are supposed to preserve this, and if there is a bug it will most likely cause the hash function to change.
This function will resize the matrix if it is empty.
Any acoustic scaling of the lattice should be done before you call this function.
'criterion' should be 'mmi', 'mpfe', or 'smbr'.
You should set drop_frames to true if you are doing MMI with drop-frames == true. Then it will not compute the hash for frames where the numerator pdf-id is not in the denominator lattice.
You can set one_silence_class to true for a newer optional behavior that will reduce insertions in the trained model (or false for the traditional behavior).
The function will also accumulate the total numerator and denominator weights used as num_weight and den_weight, for an additional diagnostic, and the total number of frames, as tot_t.
Definition at line 786 of file nnet-example-functions.cc.
References VectorBase< Real >::AddRowSumMat(), ExampleToPdfPost(), rnnlm::i, DiscriminativeNnetExample::input_frames, KALDI_ASSERT, DiscriminativeNnetExample::left_context, DiscriminativeNnetExample::num_ali, MatrixBase< Real >::NumCols(), TransitionModel::NumPdfs(), MatrixBase< Real >::NumRows(), Matrix< Real >::Resize(), and MatrixBase< Real >::Row().
Referenced by main(), and SplitExampleStats::SplitExampleStats().
void WidenNnet | ( | const NnetWidenConfig & | widen_config, |
Nnet * | nnet | ||
) |
This function widens a neural network by increasing the hidden-layer dimensions to the target.
Definition at line 62 of file widen-nnet.cc.
References NnetWidenConfig::bias_stddev, Nnet::Check(), Nnet::GetComponent(), NnetWidenConfig::hidden_layer_dim, AffineComponent::InputDim(), KALDI_LOG, Nnet::NumComponents(), AffineComponent::OutputDim(), NnetWidenConfig::param_stddev_factor, and AffineComponent::Widen().
Referenced by main(), and NnetWidenConfig::Register().
|
static |
Definition at line 156 of file nnet-example.cc.
|
static |
Definition at line 156 of file nnet-example.cc.
Referenced by NnetExample::NnetExample().