Namespaces | |
attention | |
computation_graph | |
time_height_convolution | |
utterance_splitting | |
This namespace contains things needed for the implementation of the function NnetBatchComputer::SplitUtteranceIntoTasks(). | |
Classes | |
struct | Access |
class | AffineComponent |
class | AmNnetSimple |
struct | Analyzer |
This struct exists to set up various pieces of analysis; it helps avoid the repetition of code where we compute all these things in sequence. More... | |
class | BackpropTruncationComponent |
class | BackpropTruncationComponentPrecomputedIndexes |
class | BatchedXvectorComputer |
struct | BatchedXvectorComputerOptions |
class | BatchNormComponent |
class | BinarySumDescriptor |
BinarySumDescriptor can represent either A + B, or (A if defined, else B). More... | |
class | BlockAffineComponent |
This class implements an affine transform using a block diagonal matrix e.g., one whose weight matrix is all zeros except for blocks on the diagonal. More... | |
class | BlockFactorizedTdnnComponent |
BlockFactorizedTdnnComponent is a modified form of TdnnComponent (which inherits from TdnnComponent) that is inspired by quaternion-based neural networks, but is more general and trainable– the idea is that blocks of parameters are linear functions of a smaller number parameters, where the linear function itself is trainable. More... | |
class | CachingOptimizingCompiler |
This class enables you to do the compilation and optimization in one call, and also ensures that if the ComputationRequest is identical to the previous one, the compilation process is not repeated. More... | |
struct | CachingOptimizingCompilerOptions |
class | ChainExampleMerger |
This class is responsible for arranging examples in groups that have the same strucure (i.e. More... | |
struct | ChainObjectiveInfo |
struct | CheckComputationOptions |
struct | ChunkInfo |
struct | ChunkTimeInfo |
struct ChunkTimeInfo is used by class UtteranceSplitter to output information about how we split an utterance into chunks. More... | |
struct | CindexHasher |
class | CindexSet |
struct | CindexVectorHasher |
class | ClipGradientComponent |
struct | CollapseModelConfig |
Config class for the CollapseModel function. More... | |
struct | CommandAttributes |
struct | CommandPairComparator |
struct | ComparePair |
class | Compiler |
This class creates an initial version of the NnetComputation, without any optimization or sharing of matrices. More... | |
struct | CompilerOptions |
class | Component |
Abstract base-class for neural-net components. More... | |
class | ComponentPrecomputedIndexes |
class | CompositeComponent |
CompositeComponent is a component representing a sequence of [simple] components. More... | |
class | ComputationAnalysis |
This class performs various kinds of specific analysis on top of what class Analyzer gives you immediately. More... | |
class | ComputationCache |
Class ComputationCache is used inside class CachingOptimizingCompiler to cache previously computed computations. More... | |
class | ComputationChecker |
class | ComputationExpander |
struct | ComputationGraph |
The first step in compilation is to turn the ComputationSpecification into a ComputationGraph, where for each Cindex we have a list of other Cindexes that it depends on. More... | |
class | ComputationGraphBuilder |
An abstract representation of a set of Cindexes. More... | |
class | ComputationLoopedOptimizer |
class | ComputationRenumberer |
struct | ComputationRequest |
struct | ComputationRequestHasher |
struct | ComputationRequestPtrEqual |
class | ComputationStepsComputer |
This class arranges the cindex_ids of the computation into a sequence of lists called "steps", which will correspond roughly to the commands in the compiled computation. More... | |
class | ComputationVariables |
This class relates the matrices and sub-matrices in the computation to imaginary "variables", such that we can think of the operations as operating on sets of individual variables, and we can then do analysis that lets us do optimization. More... | |
class | ConstantComponent |
class | ConstantFunctionComponent |
class | ConstantSumDescriptor |
This is an alternative base-case of SumDescriptor (an alternative to SimpleSumDescriptor) which represents a constant term, e.g. More... | |
class | ConvolutionComponent |
WARNING, this component is deprecated in favor of TimeHeightConvolutionComponent, and will be deleted. More... | |
class | DecodableAmNnetLoopedOnline |
class | DecodableAmNnetSimple |
class | DecodableAmNnetSimpleLooped |
class | DecodableAmNnetSimpleParallel |
class | DecodableNnetLoopedOnline |
class | DecodableNnetLoopedOnlineBase |
class | DecodableNnetSimple |
class | DecodableNnetSimpleLooped |
class | DecodableNnetSimpleLoopedInfo |
When you instantiate class DecodableNnetSimpleLooped, you should give it a const reference to this class, that has been previously initialized. More... | |
class | DerivativeTimeLimiter |
class | Descriptor |
class | DiscriminativeExampleMerger |
This class is responsible for arranging examples in groups that have the same strucure (i.e. More... | |
struct | DiscriminativeObjectiveFunctionInfo |
class | DistributeComponent |
This Component takes a larger input-dim than output-dim, where the input-dim must be a multiple of the output-dim, and distributes different blocks of the input dimension to different 'x' values. More... | |
class | DistributeComponentPrecomputedIndexes |
class | DropoutComponent |
class | DropoutMaskComponent |
class | ElementwiseProductComponent |
struct | ExampleGenerationConfig |
class | ExampleMerger |
This class is responsible for arranging examples in groups that have the same strucure (i.e. More... | |
class | ExampleMergingConfig |
class | ExampleMergingStats |
This class is responsible for storing, and displaying in log messages, statistics about how examples of different sizes (c.f. More... | |
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 | 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 | ForwardingDescriptor |
A ForwardingDescriptor describes how we copy data from another NetworkNode, or from multiple other NetworkNodes, possibly with a scalar weight. More... | |
struct | GeneralDescriptor |
This class is only used when parsing Descriptors. More... | |
class | GeneralDropoutComponent |
GeneralDropoutComponent implements dropout, including a continuous variant where the thing we multiply is not just zero or one, but may be a continuous value. More... | |
class | GeneralDropoutComponentPrecomputedIndexes |
struct | ImageAugmentationConfig |
struct | Index |
struct Index is intended to represent the various indexes by which we number the rows of the matrices that the Components process: mainly 'n', the index of the member of the minibatch, 't', used for the frame index in speech recognition, and 'x', which is a catch-all extra index which we might use in convolutional setups or for other reasons. More... | |
struct | IndexHasher |
struct | IndexLessNxt |
class | IndexSet |
An abstract representation of a set of Indexes. More... | |
struct | IndexVectorHasher |
struct | IoSpecification |
struct | IoSpecificationHasher |
class | LinearComponent |
class | LogSoftmaxComponent |
class | LstmNonlinearityComponent |
struct | MatrixAccesses |
class | MatrixExtender |
struct | MaxChangeStats |
class | MaxpoolingComponent |
class | MemoryCompressionOptimizer |
This class is used in the function OptimizeMemoryCompression(), once we determine that there is some potential to do memory compression for this computation. More... | |
struct | MiscComputationInfo |
class | ModelCollapser |
class | ModelUpdateConsolidator |
This class is responsible for consolidating the model-update part of backprop commands, for components in (e.g.) recurrent networks that need to have many separate backprop commands, into more efficient single commands operating on consolidated data in larger matrices. More... | |
class | NaturalGradientAffineComponent |
class | NaturalGradientPerElementScaleComponent |
NaturalGradientPerElementScaleComponent is like PerElementScaleComponent but it uses a natural gradient update for the per-element scales. More... | |
class | NaturalGradientRepeatedAffineComponent |
struct | NetworkNode |
NetworkNode is used to represent, three types of thing: either an input of the network (which pretty much just states the dimension of the input vector); a Component (e.g. More... | |
class | Nnet |
class | NnetBatchComputer |
This class does neural net inference in a way that is optimized for GPU use: it combines chunks of multiple utterances into minibatches for more efficient computation. More... | |
struct | NnetBatchComputerOptions |
class | NnetBatchDecoder |
Decoder object that uses multiple CPU threads for the graph search, plus a GPU for the neural net inference (that's done by a separate NnetBatchComputer object). More... | |
class | NnetBatchInference |
This class implements a simplified interface to class NnetBatchComputer, which is suitable for programs like 'nnet3-compute' where you want to support fast GPU-based inference on a sequence of utterances, and get them back from the object in the same order. More... | |
class | NnetChainComputeProb |
This class is for computing objective-function values in a nnet3+chain setup, for diagnostics. More... | |
struct | NnetChainExample |
NnetChainExample is like NnetExample, but specialized for lattice-free (chain) training. More... | |
struct | NnetChainExampleStructureCompare |
This comparator object compares just the structural aspects of the NnetChainExample without looking at the value of the features. More... | |
struct | NnetChainExampleStructureHasher |
This hashing object hashes just the structural aspects of the NnetExample without looking at the value of the features. More... | |
struct | NnetChainSupervision |
class | NnetChainTrainer |
This class is for single-threaded training of neural nets using the 'chain' model. More... | |
struct | NnetChainTrainingOptions |
struct | NnetComputation |
struct | NnetComputationPrintInserter |
struct | NnetComputeOptions |
class | NnetComputeProb |
This class is for computing cross-entropy and accuracy values in a neural network, for diagnostics. More... | |
struct | NnetComputeProbOptions |
class | NnetComputer |
class NnetComputer is responsible for executing the computation described in the "computation" object. More... | |
class | NnetComputerFromEg |
class | NnetDiscriminativeComputeObjf |
This class is for computing objective-function values in a nnet3 discriminative training, for diagnostics. More... | |
struct | NnetDiscriminativeExample |
NnetDiscriminativeExample is like NnetExample, but specialized for sequence training. More... | |
struct | NnetDiscriminativeExampleStructureCompare |
This comparator object compares just the structural aspects of the NnetDiscriminativeExample without looking at the value of the features. More... | |
struct | NnetDiscriminativeExampleStructureHasher |
This hashing object hashes just the structural aspects of the NnetExample without looking at the value of the features. More... | |
struct | NnetDiscriminativeOptions |
struct | NnetDiscriminativeSupervision |
class | NnetDiscriminativeTrainer |
This class is for single-threaded discriminative training of neural nets. More... | |
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... | |
struct | NnetExampleStructureCompare |
This comparator object compares just the structural aspects of the NnetExample without looking at the value of the features. More... | |
struct | NnetExampleStructureHasher |
This hashing object hashes just the structural aspects of the NnetExample without looking at the value of the features. More... | |
struct | NnetGenerationOptions |
struct | NnetInferenceTask |
class NnetInferenceTask represents a chunk of an utterance that is requested to be computed. More... | |
struct | NnetIo |
struct | NnetIoStructureCompare |
This comparison object compares just the structural aspects of the NnetIo object (name, indexes, feature dimension) without looking at the value of features. More... | |
struct | NnetIoStructureHasher |
This hashing object hashes just the structural aspects of the NnetIo object (name, indexes, feature dimension) without looking at the value of features. More... | |
class | NnetLdaStatsAccumulator |
struct | NnetOptimizeOptions |
struct | NnetSimpleComputationOptions |
struct | NnetSimpleLoopedComputationOptions |
class | NnetTrainer |
This class is for single-threaded training of neural nets using standard objective functions such as cross-entropy (implemented with logsoftmax nonlinearity and a linear objective function) and quadratic loss. More... | |
struct | NnetTrainerOptions |
class | NonlinearComponent |
class | NoOpComponent |
NoOpComponent just duplicates its input. More... | |
class | NormalizeComponent |
struct | ObjectiveFunctionInfo |
class | OffsetForwardingDescriptor |
Offsets in 't' and 'x' values of other ForwardingDescriptors. More... | |
class | OnlineNaturalGradient |
Keywords for search: natural gradient, naturalgradient, NG-SGD. More... | |
class | OnlineNaturalGradientSimple |
class | OptionalSumDescriptor |
This is the case of class SumDescriptor, in which we contain just one term, and that term is optional (an IfDefined() expression). More... | |
struct | PairIsEqualComparator |
struct | PerDimObjectiveInfo |
class | PerElementOffsetComponent |
class | PerElementScaleComponent |
PerElementScaleComponent scales each dimension of its input with a separate trainable scale; it's like a linear component with a diagonal matrix. More... | |
class | PermuteComponent |
PermuteComponent changes the order of the columns (i.e. More... | |
class | PnormComponent |
class | RandomComponent |
class | RectifiedLinearComponent |
class | RepeatedAffineComponent |
class | ReplaceIndexForwardingDescriptor |
This ForwardingDescriptor modifies the indexes (n, t, x) by replacing one of them (normally t) with a constant value and keeping the rest. More... | |
class | RestrictedAttentionComponent |
RestrictedAttentionComponent implements an attention model with restricted temporal context. More... | |
class | RoundingForwardingDescriptor |
For use in clockwork RNNs and the like, this forwarding-descriptor rounds the time-index t down to the the closest t' <= t that is an exact multiple of t_modulus_. More... | |
class | RowOpsSplitter |
class | ScaleAndOffsetComponent |
class | SigmoidComponent |
class | SimpleForwardingDescriptor |
SimpleForwardingDescriptor is the base-case of ForwardingDescriptor, consisting of a source node in the graph with a given scalar weight (which will in the normal case be 1.0). More... | |
struct | SimpleObjectiveInfo |
class | SimpleSumDescriptor |
This is the normal base-case of SumDescriptor which just wraps a ForwardingDescriptor. More... | |
class | SoftmaxComponent |
class | SpecAugmentTimeMaskComponent |
SpecAugmentTimeMaskComponent implements the time part of SpecAugment. More... | |
class | SpecAugmentTimeMaskComponentPrecomputedIndexes |
class | StatisticsExtractionComponent |
class | StatisticsExtractionComponentPrecomputedIndexes |
class | StatisticsPoolingComponent |
class | StatisticsPoolingComponentPrecomputedIndexes |
class | SumBlockComponent |
SumBlockComponent sums over blocks of its input: for instance, if you create one with the config "input-dim=400 output-dim=100", its output will be the sum over the 4 100-dimensional blocks of the input. More... | |
class | SumDescriptor |
This is an abstract base-class. More... | |
class | SumGroupComponent |
SumGroupComponent is used to sum up groups of posteriors. More... | |
class | SvdApplier |
class | SwitchingForwardingDescriptor |
Chooses from different inputs based on the the time index modulo (the number of ForwardingDescriptors given as inputs). More... | |
class | TanhComponent |
struct | TarjanNode |
class | TdnnComponent |
TdnnComponent is a more memory-efficient alternative to manually splicing several frames of input and then using a NaturalGradientAffineComponent or a LinearComponent. More... | |
class | TimeHeightConvolutionComponent |
TimeHeightConvolutionComponent implements 2-dimensional convolution where one of the dimensions of convolution (which traditionally would be called the width axis) is identified with time (i.e. More... | |
class | UpdatableComponent |
Class UpdatableComponent is a Component which has trainable parameters; it extends the interface of Component. More... | |
class | UtteranceSplitter |
class | VariableMergingOptimizer |
This class is responsible for merging matrices, although you probably want to access it via the the function VariableMergingOptimization(). More... | |
Typedefs | |
typedef TableWriter< KaldiObjectHolder< NnetChainExample > > | NnetChainExampleWriter |
typedef SequentialTableReader< KaldiObjectHolder< NnetChainExample > > | SequentialNnetChainExampleReader |
typedef RandomAccessTableReader< KaldiObjectHolder< NnetChainExample > > | RandomAccessNnetChainExampleReader |
typedef std::pair< int32, Index > | Cindex |
typedef TableWriter< KaldiObjectHolder< NnetDiscriminativeExample > > | NnetDiscriminativeExampleWriter |
typedef SequentialTableReader< KaldiObjectHolder< NnetDiscriminativeExample > > | SequentialNnetDiscriminativeExampleReader |
typedef RandomAccessTableReader< KaldiObjectHolder< NnetDiscriminativeExample > > | RandomAccessNnetDiscriminativeExampleReader |
typedef TableWriter< KaldiObjectHolder< NnetExample > > | NnetExampleWriter |
typedef SequentialTableReader< KaldiObjectHolder< NnetExample > > | SequentialNnetExampleReader |
typedef RandomAccessTableReader< KaldiObjectHolder< NnetExample > > | RandomAccessNnetExampleReader |
Functions | |
void | UnitTestPreconditionDirectionsOnline () |
std::string | PrintCommand (int32 num_commands, int32 command) |
void | UnitTestNnetAnalyze () |
static void | IndexesMultiToSubmatrixIndexes (const std::vector< std::pair< int32, int32 > > &indexes_multi, std::vector< int32 > *submatrix_indexes) |
given a vector of pairs from computation.indexes_multi_indexes containing paris (submatrix-index, row-index), this function outputs to "submatrix_indexes" all (unique) submatrix indexes that appear; and it outputs to "contains_null_marker" true if the pair (-1, -1) appears anywhere in indexes_multi, and false otherwise. More... | |
void | ComputeCommandAttributes (const Nnet &nnet, const NnetComputation &computation, const ComputationVariables &vars, std::vector< CommandAttributes > *attributes) |
void | ComputeVariableAccesses (const ComputationVariables &variables, const std::vector< CommandAttributes > &command_attributes, std::vector< std::vector< Access > > *variable_accesses) |
After the command-level attributes have been computed, this function organizes them per variable (see class ComputationVariables for how a variable is defined; it is part of a matrix). More... | |
void | ComputeMatrixAccesses (const Nnet &nnet, const NnetComputation &computation, const ComputationVariables &variables, const std::vector< CommandAttributes > &command_attributes, std::vector< MatrixAccesses > *matrix_accesses) |
This function organizes information in the CommandAttributes in a way that is convenient to access per matrix. More... | |
static void | CheckComputationOnline (const Nnet &nnet, NnetComputation computation, bool check_rewrite) |
void | CheckComputation (const Nnet &nnet, const NnetComputation &computation, bool check_rewrite=false) |
This is a convenience interface for class ComputationChecker. More... | |
void | ComputeMatrixToSubmatrix (const NnetComputation &computation, std::vector< std::vector< int32 > > *mat_to_submat) |
This function computes a vector 'mat_to_submat', indexed by matrix index, such that (*mat_to_submat)[m] is a list of all the submatrix indexes that refer to matrix m. More... | |
void | PrintMatrixAccesses (std::ostream &os, const std::vector< MatrixAccesses > &matrix_accesses) |
This function is to be used in debugging; it produces human-readable output. More... | |
void | PrintCommandAttributes (std::ostream &os, const std::vector< CommandAttributes > &attributes) |
This function is to be used in debugging; it produces human-readable output. More... | |
void | GetCommandsOfType (const NnetComputation &computation, CommandType t, std::vector< int32 > *command_indexes) |
This utility function works out from a computation, the command-indexes of the commands of the given type. More... | |
int64 | GetMaxMemoryUse (const NnetComputation &computation) |
int32 | MaxMemoryUsage (const NnetComputation &computation) |
Returns the total memory, in bytes, used by the computation (just the temporary memory, not counting the memory used by the nnet itself). More... | |
void | MergeTaskOutput (const std::vector< NnetInferenceTask > &tasks, Matrix< BaseFloat > *output) |
Merges together the 'output_cpu' (if the 'output_to_cpu' members are true) or the 'output' members of 'tasks' into a single CPU matrix 'output'. More... | |
void | MergeTaskOutput (const std::vector< NnetInferenceTask > &tasks, CuMatrix< BaseFloat > *output) |
static bool | HasXentOutputs (const Nnet &nnet) |
void | RecomputeStats (const std::vector< NnetChainExample > &egs, const chain::ChainTrainingOptions &chain_config, const fst::StdVectorFst &den_fst, Nnet *nnet) |
This function zeros the stored component-level stats in the nnet using ZeroComponentStats(), then recomputes them with the supplied egs. More... | |
static void | MergeSupervision (const std::vector< const NnetChainSupervision *> &inputs, NnetChainSupervision *output) |
void | MergeChainExamples (bool compress, std::vector< NnetChainExample > *input, NnetChainExample *output) |
This function merges a list of NnetChainExample objects into a single one– intended to be used when forming minibatches for neural net training. More... | |
void | GetChainComputationRequest (const Nnet &nnet, const NnetChainExample &eg, bool need_model_derivative, bool store_component_stats, bool use_xent_regularization, bool use_xent_derivative, ComputationRequest *computation_request) |
This function takes a NnetChainExample and produces a ComputationRequest. More... | |
void | ShiftChainExampleTimes (int32 frame_shift, const std::vector< std::string > &exclude_names, NnetChainExample *eg) |
Shifts the time-index t of everything in the input of "eg" by adding "t_offset" to all "t" values– but excluding those with names listed in "exclude_names", e.g. More... | |
int32 | GetNnetChainExampleSize (const NnetChainExample &a) |
int32 | GetChainNnetExampleSize (const NnetChainExample &a) |
This function returns the 'size' of a chain example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example. More... | |
int32 | YzxVectorIndex (int32 x, int32 y, int32 z, int32 input_x_dim, int32 input_y_dim, int32 input_z_dim) |
int32 | ZyxVectorIndex (int32 x, int32 y, int32 z, int32 input_x_dim, int32 input_y_dim, int32 input_z_dim) |
void | RearrangeIndexes (const std::vector< std::vector< int32 > > &in, std::vector< std::vector< int32 > > *out) |
void | UnitTestIndexIo () |
void | UnitTestCindexIo () |
static void | WriteIndexVectorElementBinary (std::ostream &os, const std::vector< Index > &vec, int32 i) |
static void | ReadIndexVectorElementBinary (std::istream &is, int32 i, std::vector< Index > *vec) |
void | WriteIndexVector (std::ostream &os, bool binary, const std::vector< Index > &vec) |
void | ReadIndexVector (std::istream &is, bool binary, std::vector< Index > *vec) |
static void | WriteCindexVectorElementBinary (std::ostream &os, const std::vector< Cindex > &vec, int32 i) |
static void | ReadCindexVectorElementBinary (std::istream &is, int32 i, std::vector< Cindex > *vec) |
void | WriteCindexVector (std::ostream &os, bool binary, const std::vector< Cindex > &vec) |
void | ReadCindexVector (std::istream &is, bool binary, std::vector< Cindex > *vec) |
std::ostream & | operator<< (std::ostream &ostream, const Index &index) |
std::ostream & | operator<< (std::ostream &ostream, const Cindex &cindex) |
void | PrintCindex (std::ostream &os, const Cindex &cindex, const std::vector< std::string > &node_names) |
void | PrintIndexes (std::ostream &ostream, const std::vector< Index > &indexes) |
this will only be used for pretty-printing. More... | |
void | PrintCindexes (std::ostream &ostream, const std::vector< Cindex > &cindexes, const std::vector< std::string > &node_names) |
this will only be used for pretty-printing. More... | |
void | PrintIntegerVector (std::ostream &os, const std::vector< int32 > &ints) |
void | AppendCindexes (int32 node, const std::vector< Index > &indexes, std::vector< Cindex > *out) |
Appends to 'out' the pairs (node, indexes[0]), (node, indexes[1]), ... More... | |
void | ModifyNnetIvectorPeriod (int32 ivector_period, Nnet *nnet) |
This function modifies the descriptors in the neural network to change the periodicity with which it expects to read an iVector at its input. More... | |
int32 | GetChunkSize (const Nnet &nnet, int32 frame_subsampling_factor, int32 advised_chunk_size) |
template<class I > | |
I | Mod (I m, I n) |
Mod(m, n), defined for integers m and n where n > 0, returns the modulus m % n, defined as the integer 0 <= i < n such that i and m are congruent modulo n; for instance, Mod(13, 10) = 3. More... | |
static void | CreateComputationRequestInternal (int32 begin_input_t, int32 end_input_t, int32 begin_output_t, int32 end_output_t, int32 num_sequences, int32 frame_subsampling_factor, const std::set< int32 > &ivector_times, ComputationRequest *request) |
void | CreateLoopedComputationRequest (const Nnet &nnet, int32 chunk_size, int32 frame_subsampling_factor, int32 ivector_period, int32 left_context_begin, int32 right_context, int32 num_sequences, ComputationRequest *request1, ComputationRequest *request2, ComputationRequest *request3) |
This function creates computation request suitable for giving to ComputeLooped(). More... | |
void | AddTimeOffsetToComputationRequest (int32 t_offset, ComputationRequest *request) |
static bool | ExtrapolateComputationRequest (const ComputationRequest &request1, const ComputationRequest &request2, ComputationRequest *request3) |
static bool | CompileLoopedInternal (const Nnet &nnet, NnetOptimizeOptions optimize_opts, const ComputationRequest &request1, const ComputationRequest &request2, const ComputationRequest &request3, int32 num_requests, NnetComputation *computation) |
void | CompileLooped (const Nnet &nnet, const NnetOptimizeOptions &optimize_opts, const ComputationRequest &request1, const ComputationRequest &request2, const ComputationRequest &request3, NnetComputation *computation) |
CompileLooped() provides an internal interface for 'looped' computation. More... | |
void | CreateLoopedComputationRequestSimple (const Nnet &nnet, int32 chunk_size, int32 frame_subsampling_factor, int32 ivector_period, int32 extra_left_context_begin, int32 extra_right_context, int32 num_sequences, ComputationRequest *request1, ComputationRequest *request2, ComputationRequest *request3) |
This function is deprecated. More... | |
void | UnitTestNnetCompile () |
void | UnitTestNnetCompileMulti () |
void | UnitTestNnetCompileLooped () |
void | PrintVectorVectorPair (std::vector< std::vector< std::pair< int32, int32 > > > vec_vec_pair) |
void | UnitTestSplitLocationsBackward (bool verbose) |
void | UnitTestHasContiguousProperty () |
void | UnitTestEnsureContiguousProperty () |
void | UnitTestSplitLocations (bool verbose) |
void | GetSubmatCounts (const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::unordered_map< int32, int32 > *submat_counts, std::vector< int32 > *submats_with_large_counts) |
Gets counts of submatrices (the 1st members of pairs) in submat_lists. More... | |
void | SeparateSubmatsWithLargeCounts (const std::vector< int32 > &submats_to_separate, const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *reduced_submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists) |
This function, used in SplitLocations(), is used to make separate 'split lists' for certain high-count submatrix indexes, specified by the user in 'submats_to_separate'. More... | |
void | SplitLocations (const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists) |
The input to this function is a vector (indexed by matrix-row-index) of lists of pairs (submat_index, row_index), and this function splits it up into a list of vectors of pairs, where those vectors are indexed by matrix-row-index. More... | |
bool | ConvertToIndexes (const std::vector< std::pair< int32, int32 > > &location_vector, int32 *first_value, std::vector< int32 > *second_values) |
If it is the case for some i >= 0 that all the .first elements of "location_vector" are either i or -1, then output i to first_value and the .second elements into "second_values", and return true. More... | |
void | EnsureContiguousProperty (const std::vector< int32 > &indexes, std::vector< std::vector< int32 > > *indexes_out) |
This function takes a vector of indexes and splits it up into as separate vectors of the same size, as needed to ensure that the 'contiguous property' holds. More... | |
void | SplitPairList (std::vector< std::pair< int32, int32 > > &list, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists) |
This function splits a vector of pairs into a list of vectors of pairs. More... | |
void | SplitLocationsBackward (const std::vector< std::vector< std::pair< int32, int32 > > > &submat_lists, std::vector< std::vector< std::pair< int32, int32 > > > *split_lists) |
This function has the same interface as SplitLocations(); however, it ensures certain additional properties of the output "split_lists", which are necessary because of the way it is used in backprop code. More... | |
bool | HasContiguousProperty (const std::vector< int32 > &indexes, std::vector< std::pair< int32, int32 > > *reverse_indexes) |
This function returns true if for each integer i != -1, all the indexes j at which indexes[j] == i are consecutive with no gaps (more formally: if j1 < j2 < j3 and indexes[j1] != -1 and indexes[j1] == indexes[j3], then indexes[j1] == indexes[j2]). More... | |
void | GetNxList (const std::vector< Index > &indexes, std::vector< std::pair< int32, int32 > > *pairs) |
This function outputs a unique, lexicographically sorted list of the pairs of (n, x) values that are encountered in the provided list of Indexes. More... | |
void | GetTList (const std::vector< Index > &indexes, std::vector< int32 > *t_values) |
This function outputs a sorted, unique list of the 't' values that are encountered in the provided list of Indexes If 't' values equal to kNoTime are encountered, they are ignored and are not output. More... | |
static void | ResetSeed (int32 rand_seed, const Component &c) |
bool | CheckStringsApproxEqual (const std::string &a, const std::string &b, int32 tolerance=3) |
void | TestNnetComponentIo (Component *c) |
void | TestNnetComponentCopy (Component *c) |
void | TestNnetComponentAddScale (Component *c) |
void | TestNnetComponentVectorizeUnVectorize (Component *c) |
void | TestNnetComponentUpdatable (Component *c) |
ComponentPrecomputedIndexes * | GetPrecomputedIndexes (const Component &c, int32 num_rows) |
void | TestSimpleComponentPropagateProperties (const Component &c) |
bool | TestSimpleComponentDataDerivative (const Component &c, BaseFloat perturb_delta) |
bool | TestSimpleComponentModelDerivative (const Component &c, BaseFloat perturb_delta, bool test_derivative) |
void | UnitTestNnetComponent () |
std::ostream & | operator<< (std::ostream &os, const ComputationGraphBuilder::ComputableInfo &info) |
This is to be used in logging only. More... | |
void | ComputeComputationGraph (const Nnet &nnet, const ComputationRequest &request, ComputationGraph *graph) |
static int32 | SumVectorSizes (const std::vector< std::vector< int32 > > &vec) |
static int32 | SumVectorSizes (const std::vector< std::vector< std::vector< int32 > > > &vec) |
static void | ComputeComputationPhasesForEpoch (const Nnet &nnet, const ComputationGraph &graph, const std::vector< int32 > &this_epoch, const std::vector< std::vector< int32 > > &dependencies_subset, const std::vector< std::vector< int32 > > &depend_on_subset, bool epoch_is_trivial, std::vector< int32 > *phase_indexes, std::vector< std::vector< int32 > > *phases) |
void | ComputeComputationPhases (const Nnet &nnet, const ComputationGraph &computation_graph, std::vector< std::vector< std::vector< int32 > > > *phases_per_segment) |
This function divides a computation into 'phases', where a 'phase' is a collection of cindexes which can (as far as the computation graph is concerned) all be computed at the same time, and depend only on cindexes previously computed in earlier phases. More... | |
static void | GetIndexesStrings (const Nnet &nnet, const NnetComputation &computation, std::vector< std::string > *indexes_strings) |
static void | GetIndexesMultiStrings (const Nnet &nnet, const NnetComputation &computation, std::vector< std::string > *indexes_multi_strings) |
static void | PrintCommand (std::ostream &os_out, const Nnet &nnet, const NnetComputation &computation, int32 command_index, const std::vector< std::string > &submatrix_strings, const std::vector< std::string > &indexes_strings, const std::vector< std::string > &indexes_multi_strings) |
static void | PrintComputationPreamble (std::ostream &os, const NnetComputation &c, const Nnet &nnet, const std::vector< std::string > &submatrix_strings, const std::vector< std::string > &indexes_strings, const std::vector< std::string > &indexes_multi_strings) |
void | UnitTestNnetComputationIo (NnetComputation *computation) |
void | UnitTestComputationRequestIo (ComputationRequest *request) |
void | TestNnetDecodable (Nnet *nnet) |
void | UnitTestNnetCompute () |
void | ComputeMinAndMaxTimes (const std::vector< Index > &indexes, int32 *min_t, int32 *max_t) |
void | SetDerivTimesOptions (const ComputationRequest &request, NnetOptimizeOptions *opt_config) |
void | UnitTestNnetModelDerivatives () |
void | UnitTestNnetInputDerivatives () |
ForwardingDescriptor * | GenRandForwardingDescriptor (int32 num_nodes) |
SumDescriptor * | GenRandSumDescriptor (int32 num_nodes) |
void | GenRandDescriptor (int32 num_nodes, Descriptor *desc) |
void | UnitTestDescriptorIo () |
void | UnitTestGeneralDescriptor () |
std::string | NormalizeTextDescriptor (const std::vector< std::string > &node_names, const std::string &desc_str) |
void | UnitTestGeneralDescriptorSpecial () |
static std::string | ParsingContext (const std::string *token_ptr) |
static void | ExpectToken (const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token) |
static int32 | ReadIntegerToken (const std::string &what_we_are_parsing, const std::string **next_token) |
void | ComputeAccuracy (const GeneralMatrix &supervision, const CuMatrixBase< BaseFloat > &nnet_output, BaseFloat *tot_weight, BaseFloat *tot_accuracy, VectorBase< BaseFloat > *tot_weight_vec=NULL, VectorBase< BaseFloat > *tot_accuracy_vec=NULL) |
This function computes the frame accuracy for this minibatch. More... | |
void | MergeSupervision (const std::vector< const NnetDiscriminativeSupervision *> &inputs, NnetDiscriminativeSupervision *output) |
void | MergeDiscriminativeExamples (bool compress, std::vector< NnetDiscriminativeExample > *input, NnetDiscriminativeExample *output) |
void | GetDiscriminativeComputationRequest (const Nnet &nnet, const NnetDiscriminativeExample &eg, bool need_model_derivative, bool store_component_stats, bool use_xent_regularization, bool use_xent_derivative, ComputationRequest *computation_request) |
This function takes a NnetDiscriminativeExample and produces a ComputationRequest. More... | |
void | ShiftDiscriminativeExampleTimes (int32 frame_shift, const std::vector< std::string > &exclude_names, NnetDiscriminativeExample *eg) |
Shifts the time-index t of everything in the input of "eg" by adding "t_offset" to all "t" values– but excluding those with names listed in "exclude_names", e.g. More... | |
int32 | GetNnetDiscriminativeExampleSize (const NnetDiscriminativeExample &a) |
void | MergeDiscriminativeExamples (std::vector< NnetDiscriminativeExample > *input, bool compress, NnetDiscriminativeExample *output) |
Appends the given vector of examples (which must be non-empty) into a single output example. More... | |
int32 | GetDiscriminativeNnetExampleSize (const NnetDiscriminativeExample &a) |
This function returns the 'size' of a discriminative example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example. More... | |
void | UnitTestNnetExample () |
void | UnitTestNnetMergeExamples () |
static void | GetIoNames (const std::vector< NnetExample > &src, std::vector< std::string > *names_vec) |
static void | GetIoSizes (const std::vector< NnetExample > &src, const std::vector< std::string > &names, std::vector< int32 > *sizes) |
static void | MergeIo (const std::vector< NnetExample > &src, const std::vector< std::string > &names, const std::vector< int32 > &sizes, bool compress, NnetExample *merged_eg) |
void | MergeExamples (const std::vector< NnetExample > &src, bool compress, NnetExample *dest) |
Merge a set of input examples into a single example (typically the size of "src" will be the minibatch size). More... | |
void | ShiftExampleTimes (int32 t_offset, const std::vector< std::string > &exclude_names, NnetExample *eg) |
Shifts the time-index t of everything in the "eg" by adding "t_offset" to all "t" values. More... | |
void | GetComputationRequest (const Nnet &nnet, const NnetExample &eg, bool need_model_derivative, bool store_component_stats, ComputationRequest *computation_request) |
This function takes a NnetExample (which should already have been frame-selected, if desired, and merged into a minibatch) and produces a ComputationRequest. More... | |
void | WriteVectorAsChar (std::ostream &os, bool binary, const VectorBase< BaseFloat > &vec) |
void | ReadVectorAsChar (std::istream &is, bool binary, Vector< BaseFloat > *vec) |
void | RoundUpNumFrames (int32 frame_subsampling_factor, int32 *num_frames, int32 *num_frames_overlap) |
int32 | GetNnetExampleSize (const NnetExample &a) |
This function returns the 'size' of a nnet-example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example. More... | |
static void | CopyPairVector (const CuArray< Int32Pair > &in, std::vector< std::pair< int32, int32 > > *out) |
static void | CopyPairVector (const std::vector< std::pair< int32, int32 > > &in, CuArray< Int32Pair > *out) |
bool | AssertGraphEqual (const std::vector< std::vector< int32 > > &graph1, const std::vector< std::vector< int32 > > &graph2) |
bool | AssertVectorEqual (const std::vector< int32 > &vec1, const std::vector< int32 > &vec2) |
void | BuildTestGraph (std::vector< std::vector< int32 > > *graph) |
void | BuildTestGraphTranspose (std::vector< std::vector< int32 > > *graph) |
void | BuildTestSccs (std::vector< std::vector< int32 > > *sccs) |
void | BuildTestSccGraph (std::vector< std::vector< int32 > > *scc_graph) |
void | BuildTestTopSortOrder (std::vector< int32 > *node_to_order) |
void | UnitTestComputeGraphTranspose () |
void | UnitTestFindSccs () |
void | UnitTestMakeSccGraph () |
void | UnitTestComputeTopSortOrder () |
void | UnitTestComputeTopSortOrder2 () |
void | NnetToDirectedGraph (const Nnet &nnet, std::vector< std::vector< int32 > > *graph) |
This function takes an nnet and turns it to a directed graph on nodes. More... | |
void | ComputeGraphTranspose (const std::vector< std::vector< int32 > > &graph, std::vector< std::vector< int32 > > *graph_transpose) |
Outputs a graph in which the order of arcs is reversed. More... | |
void | TarjanSccRecursive (int32 node, const std::vector< std::vector< int32 > > &graph, int32 *global_index, std::vector< TarjanNode > *tarjan_nodes, std::vector< int32 > *tarjan_stack, std::vector< std::vector< int32 > > *sccs) |
void | FindSccsTarjan (const std::vector< std::vector< int32 > > &graph, std::vector< std::vector< int32 > > *sccs) |
void | FindSccs (const std::vector< std::vector< int32 > > &graph, std::vector< std::vector< int32 > > *sccs) |
Given a directed graph (where each std::vector<int32> is a list of destination-nodes of arcs coming from the current node), partition it into strongly connected components (i.e. More... | |
void | MakeSccGraph (const std::vector< std::vector< int32 > > &graph, const std::vector< std::vector< int32 > > &sccs, std::vector< std::vector< int32 > > *scc_graph) |
Given a list of sccs of a graph (e.g. More... | |
void | ComputeTopSortOrderRecursive (int32 node, const std::vector< std::vector< int32 > > &graph, std::vector< bool > *cycle_detector, std::vector< bool > *is_visited, std::vector< int32 > *reversed_orders) |
void | ComputeTopSortOrder (const std::vector< std::vector< int32 > > &graph, std::vector< int32 > *node_to_order) |
Given an acyclic graph (where each std::vector<int32> is a list of destination-nodes of arcs coming from the current node), compute a topological ordering of the graph nodes. More... | |
std::string | PrintGraphToString (const std::vector< std::vector< int32 > > &graph) |
Prints a graph to a string in a pretty way for human readability, e.g. More... | |
void | ComputeNnetComputationEpochs (const Nnet &nnet, std::vector< int32 > *node_to_epoch) |
This function computes the order in which we need to compute each node in the graph, where each node-index n maps to an epoch-index t = 0, 1, ... More... | |
bool | GraphHasCycles (const std::vector< std::vector< int32 > > &graph) |
This function returns 'true' if the graph represented in 'graph' contains cycles (including cycles where a single node has an arc to itself). More... | |
void | UnitTestNnetIo () |
static bool | UnitTestNnetOptimizeWithOptions (int32 srand_seed, NnetOptimizeOptions opt_config, CachingOptimizingCompilerOptions compiler_config) |
static void | UnitTestNnetOptimizeInternal (int32 srand_seed) |
static void | UnitTestNnetOptimize () |
void | IdentifySubmatrixArgs (NnetComputation::Command *command, std::vector< int32 * > *submatrix_args) |
This function outputs to "submatrix_args" the addresses of a subset of arguments arg1 through arg6 in "command", that correspond to the indexes of submatrices. More... | |
void | IdentifySubmatrixArgs (std::vector< NnetComputation::Command > *commands, std::vector< int32 * > *submatrix_args) |
This function outputs to "submatrix_args" the addresses of the args (arguments arg1 through arg6) in the vector "commands", that correspond to the indexes of submatrices. More... | |
void | IdentifyMatrixArgsInComputation (NnetComputation *computation, std::vector< int32 *> *matrix_args) |
void | IdentifyIndexesMultiArgs (std::vector< NnetComputation::Command > *commands, std::vector< int32 * > *indexes_multi_args) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's indexes_multi array, and outputs a list of pointers to those arguments to 'indexes_multi_args'. More... | |
void | IdentifyIndexesRangesArgs (std::vector< NnetComputation::Command > *commands, std::vector< int32 * > *indexes_ranges_args) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's 'indexes_ranges' array, and outputs a list of pointers to those arguments to 'indexes_ranges_args'. More... | |
void | IdentifyIndexesArgs (std::vector< NnetComputation::Command > *commands, std::vector< int32 * > *indexes_args) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's 'indexes' array, and outputs a list of pointers to those arguments to 'indexes_args'. More... | |
void | IdentifySubmatrixArgsInComputation (NnetComputation *computation, std::vector< int32 * > *submatrix_args) |
This function outputs to "submatrix_args" the addresses of integers in 'computation' that correspond to submatrices. More... | |
void | RenumberComputation (NnetComputation *computation) |
This function detects submatrices and matrices that are never used (e.g. More... | |
static bool | IsNoop (const NnetComputation::Command &command) |
void | RemoveNoOps (NnetComputation *computation) |
Removes commands of type kNoOperation in the computation. More... | |
static NnetComputation::SubMatrixInfo | GetSubMatrixOfSubMatrix (const NnetComputation &computation, int32 submat_a, int32 submat_b) |
This static function returns a SubMatrixInfo corresponding to replacing the matrix-index in a's "matrix_index" with, essentially, sub-matrix b. More... | |
void | ExtendMatrices (NnetComputation *computation) |
This is not really an optimization in itself but it can make things easier for class VariableMergingOptimizer (usually called by its wrapper VariableMergingOptimization()). More... | |
void | ConsolidateModelUpdate (const Nnet &nnet, NnetComputation *computation) |
This optimization consolidates the model-update part of backprop commands, for components in (e.g.) recurrent networks that need to have many separate backprop commands, into more efficient single commands operating on consolidated data in larger matrices. More... | |
void | LimitDerivativeTimes (const Nnet &nnet, int32 min_deriv_time, int32 max_deriv_time, NnetComputation *computation) |
static bool | IndexesHaveSpecialStructure (const std::vector< int32 > &indexes, int32 *first_nonnegative_pos, int32 *first_nonnegative_value, int32 *num_nonnegative_indexes) |
bool | ReplaceRowWithMatrixOps (NnetComputation *computation) |
This function detects cases where commands of type kCopyRows, kAddRows or kAddToRows can be converted to commands of type kMatrixCopy or kMatrixAdd, and converts them (this may involve adding submatrices). More... | |
static void | FindNumLeadingAndTrailingNegatives (const std::vector< int32 > &vec, int32 *num_leading_negatives, int32 *num_trailing_negatives) |
static bool | SnipSingleRowOp (NnetComputation *computation, int32 command_index) |
static void | FindNumLeadingAndTrailingNegatives (const std::vector< std::pair< int32, int32 > > &vec, int32 *num_leading_negatives, int32 *num_trailing_negatives) |
static bool | SnipMultiRowOp (NnetComputation *computation, int32 command_index) |
static void | FindNumLeadingAndTrailingIdenticals (const std::vector< std::pair< int32, int32 > > &vec, int32 *num_leading_identicals, int32 *num_trailing_identicals) |
static bool | SnipRangesRowOp (NnetComputation *computation, int32 command_index) |
bool | SnipRowOps (NnetComputation *computation) |
This function detects cases where commands of type kCopyRows, kAddRows, kAddRowsMulti, kAddToRowsMulti, kCopyRowsMulti, kCopyToRowsMulti or kAddRowRanges use indexes that start or end with -1's or equivalents, and replace them with similar commands that act on a sub-matrix of the matrices they are currently acting on. More... | |
bool | SplitRowOps (NnetComputation *computation) |
This function detects cases where commands of type kAddRowsMulti, kAddToRowsMulti, kCopyRowsMulti, kCopyToRowsMulti use indexes that correspond to at most two submatrices, in two distinct ranges without gaps filled by -1's, and could be converted to at most two commands of type kMatrixAdd, kMatrixCopy, kAddRows or kCopyRows. More... | |
static int32 | FindNStride (const std::vector< Index > &indexes, bool full_check) |
static int32 | FindNStride (const std::vector< Cindex > &cindexes, bool full_check) |
static void | ConvertNumNValues (int32 n_stride, int32 old_N, int32 new_N, const std::vector< Index > &indexes_in, std::vector< Index > *indexes_out) |
void | ExpandComputation (const Nnet &nnet, const MiscComputationInfo &misc_info, const NnetComputation &computation, bool need_debug_info, int32 num_n_values, NnetComputation *expanded_computation) |
This function is used in 'shortcut' compilation to expand a computation that has been compiled for exactly 2 'n' values, to one that is suitable for some num_n_values > 2. More... | |
static bool | IoSpecificationIsDecomposable (const IoSpecification &io_spec, IoSpecification *mini_io_spec, int32 *num_n_values_out) |
bool | RequestIsDecomposable (const ComputationRequest &request, ComputationRequest *mini_request, int32 *num_n_values) |
This function, used in 'shortcut' compilation where we first compile a smaller computation with the same structure but only 2 distinct 'n' values, works out whether a computation is 'decomposable'; if so, it returns true and outputs the 'mini_request' with the same structure, and the number of 'n' values. More... | |
void | OptimizeLoopedComputation (const Nnet &nnet, NnetComputation *computation) |
This function tries to optimize computation 'computation' for an 'looped' computation. More... | |
void | FixGotoLabel (NnetComputation *computation) |
This function ensures that the arg1 of a final command of type kGotoLabel is the same as the command with type kNoOperationLabel. More... | |
bool | MatrixIsUnused (const Analyzer &analyzer, const NnetComputation &computation, int32 m) |
This function returns true if matrix 1 <= m < computation->matrices.size() is unused, defined as: it is not an input or an output, and is not accessed other than via commands of type kAllocMatrix, kDeallocMatrix, and kSetConst. More... | |
void | RemoveCommandsForUnusedMatrix (const Analyzer &analyzer, int32 m, NnetComputation *computation) |
This function removes from 'computation' the commands accessing matrix 'm', which is assumed to be unused according to the MatrixIsUnused() command above. More... | |
void | InsertCommands (std::vector< std::pair< int32, NnetComputation::Command > > *commands, NnetComputation *computation) |
Inserts commands into the computation at the requested places. More... | |
void | OptimizeMemoryCompression (const Nnet &nnet, int32 memory_compression_level, NnetComputation *computation) |
Performs optimization to reduce memory usage where possible, making use of the kCompressMatrix and kDecompressMatrix commands. More... | |
int32 | MaxOutputTimeInRequest (const ComputationRequest &request) |
void | MoveSizingCommands (const Nnet &nnet, NnetComputation *computation) |
This optimization moves commands that allocate and zero matrices to as late as possible, and moves commands that deallocate matrices to as early as possible. More... | |
void | RemoveUnnecessaryZeroing (const Nnet &nnet, NnetComputation *computation) |
This optimization function removes, where possible, commands of type type kSetConst. More... | |
static void | ComputeCommandPairs (const std::pair< std::vector< int32 >, std::vector< int32 > > &lists, std::vector< std::pair< int32, int32 > > *pairs) |
void | RemoveUnnecessaryAllocation (const Nnet &nnet, NnetComputation *computation) |
This optimization detects cases where we deallocate a matrix, and then later allocate another matrix of the same size; and replaces them with commands of type kAllocFromOther or kAllocFromOtherZeroed. More... | |
void | VariableMergingOptimization (const NnetOptimizeOptions &config, const Nnet &nnet, NnetComputation *computation) |
This wraps class VariableMergingOptimizer in a simplified interface. More... | |
void | ConvertAdditionToAssignment (const Nnet &nnet, NnetComputation *computation) |
This converts addition operations (things with Add in their names) to copy operations (things with Copy in their names). More... | |
void | Optimize (const NnetOptimizeOptions &config, const Nnet &nnet, int32 max_output_time_in_request, NnetComputation *computation) |
This is the top-level function for optimizing a computation. More... | |
static void | SplitComputationIntoSegments (const NnetComputation &computation, std::vector< std::pair< int32, int32 > > *segments) |
Split the computation up into segments bounded by kNoOperationMarker. More... | |
void | ConsolidateIoOperations (const Nnet &nnet, NnetComputation *computation) |
This optimization puts the input operations (kAcceptInput) and output operations (kProvideOutput) at the very beginning or end of segments of computation, respectively. More... | |
void | LimitDerivativeTimes (const Nnet &nnet, const ComputationRequest &request, const NnetOptimizeOptions &opts, NnetComputation *computation) |
This optimization, which has no effect unless you set –min-deriv-time or –max-deriv-time, modifies the backprop operations for efficiency based on the assumption that derivatives for any Cindex with t < min_deriv_time or t > max_deriv_time are zero. More... | |
void | UnitTestDescriptorTokenize () |
void | UnitTestSummarizeVector () |
void | UnitTestNameMatchesPattern () |
bool | DescriptorTokenize (const std::string &input, std::vector< std::string > *tokens) |
This function tokenizes input when parsing Descriptor configuration values. More... | |
std::string | ErrorContext (std::istream &is) |
Return a string used in error messages. More... | |
std::string | ErrorContext (const std::string &str) |
static void | PrintFloatSuccinctly (std::ostream &os, BaseFloat f) |
std::string | SummarizeVector (const VectorBase< float > &vec) |
Returns a string that summarizes a vector fairly succintly, for printing stats in info lines. More... | |
std::string | SummarizeVector (const VectorBase< double > &vec) |
std::string | SummarizeVector (const CuVectorBase< BaseFloat > &cu_vec) |
void | PrintParameterStats (std::ostringstream &os, const std::string &name, const CuVectorBase< BaseFloat > ¶ms, bool include_mean=false) |
Print to 'os' some information about the mean and standard deviation of some parameters, used in Info() functions in nnet-simple-component.cc. More... | |
void | PrintParameterStats (std::ostringstream &os, const std::string &name, const CuMatrix< BaseFloat > ¶ms, bool include_mean=false, bool include_row_norms=false, bool include_column_norms=false, bool include_singular_values=false) |
Print to 'os' some information about the mean and standard deviation of some parameters, used in Info() functions in nnet-simple-component.cc. More... | |
void | ParseConfigLines (const std::vector< std::string > &lines, std::vector< ConfigLine > *config_lines) |
bool | NameMatchesPattern (const char *name, const char *pattern) |
void | GenerateConfigSequenceSimplest (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceSimpleContext (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceSimple (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceStatistics (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceRnn (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceRnnClockwork (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceLstm (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceLstmWithTruncation (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceLstmType2 (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceCnn (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceCnnNew (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceRestrictedAttention (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceDistribute (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
void | GenerateConfigSequenceCompositeBlock (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
Generate a config string with a composite component composed only of block affine, repeated affine, and natural gradient repeated affine components. More... | |
void | GenerateConfigSequence (const NnetGenerationOptions &opts, std::vector< std::string > *configs) |
Generates a sequence of at least one config files, output as strings, where the first in the sequence is the initial nnet, and the remaining ones may do things like add layers. More... | |
void | ComputeExampleComputationRequestSimple (const Nnet &nnet, ComputationRequest *request, std::vector< Matrix< BaseFloat > > *inputs) |
This function computes an example computation request, for testing purposes. More... | |
static void | GenerateRandomComponentConfig (std::string *component_type, std::string *config) |
Component * | GenerateRandomSimpleComponent () |
Generates random simple component for testing. More... | |
bool | NnetParametersAreIdentical (const Nnet &nnet1, const Nnet &nnet2, BaseFloat threshold) |
Used for testing that the updatable parameters in two networks are the same. More... | |
void | GenerateSimpleNnetTrainingExample (int32 num_supervised_frames, int32 left_context, int32 right_context, int32 input_dim, int32 output_dim, int32 ivector_dim, NnetExample *example) |
Low-level function that generates an nnet training example. More... | |
bool | ExampleApproxEqual (const NnetExample &eg1, const NnetExample &eg2, BaseFloat delta) |
Returns true if the examples are approximately equal (only intended to be used in testing). More... | |
void | ComputeObjectiveFunction (const GeneralMatrix &supervision, ObjectiveType objective_type, const std::string &output_name, bool supply_deriv, NnetComputer *computer, BaseFloat *tot_weight, BaseFloat *tot_objf) |
This function computes the objective function, and if supply_deriv = true, supplies its derivative to the NnetComputation object. More... | |
void | UnitTestNnetContext () |
void | UnitTestConvertRepeatedToBlockAffine () |
void | UnitTestConvertRepeatedToBlockAffineComposite () |
int32 | NumOutputNodes (const Nnet &nnet) |
returns the number of output nodes of this nnet. More... | |
int32 | NumInputNodes (const Nnet &nnet) |
returns the number of input nodes of this nnet. More... | |
bool | IsSimpleNnet (const Nnet &nnet) |
This function returns true if the nnet has the following properties: It has an output called "output" (other outputs are allowed but may be ignored). More... | |
void | EvaluateComputationRequest (const Nnet &nnet, const ComputationRequest &request, std::vector< std::vector< bool > > *is_computable) |
Given an nnet and a computation request, this function works out which requested outputs in the computation request are computable; it outputs this information as a vector "is_computable" indexed by the same indexes as request.outputs. More... | |
static bool | ComputeSimpleNnetContextForShift (const Nnet &nnet, int32 input_start, int32 window_size, int32 *left_context, int32 *right_context) |
void | ComputeSimpleNnetContext (const Nnet &nnet, int32 *left_context, int32 *right_context) |
ComputeSimpleNnetContext computes the left-context and right-context of a nnet. More... | |
void | PerturbParams (BaseFloat stddev, Nnet *nnet) |
Calls PerturbParams (with the given stddev) on all updatable components of the nnet. More... | |
void | ComponentDotProducts (const Nnet &nnet1, const Nnet &nnet2, VectorBase< BaseFloat > *dot_prod) |
Returns dot products between two networks of the same structure (calls the DotProduct functions of the Updatable components and fill in the output vector). More... | |
std::string | PrintVectorPerUpdatableComponent (const Nnet &nnet, const VectorBase< BaseFloat > &vec) |
This function is for printing, to a string, a vector with one element per updatable component of the nnet (e.g. More... | |
BaseFloat | DotProduct (const Nnet &nnet1, const Nnet &nnet2) |
Returns dot product between two networks of the same structure (calls the DotProduct functions of the Updatable components and sums up the return values). More... | |
void | ZeroComponentStats (Nnet *nnet) |
Zeroes the component stats in all nonlinear components in the nnet. More... | |
void | SetLearningRate (BaseFloat learning_rate, Nnet *nnet) |
Sets the underlying learning rate for all the components in the nnet to this value. More... | |
void | SetNnetAsGradient (Nnet *nnet) |
Sets nnet as gradient by Setting is_gradient_ to true and learning_rate_ to 1 for each UpdatableComponent in nnet. More... | |
void | SetRequireDirectInput (bool b, Nnet *nnet) |
Calls the corresponding function in any component of type StatisticsPoolingComponent; used as a way to compute the 'real' left-right context of networks including SatisticsPoolingComponent, which will give you the minimum chunk size they can consume. More... | |
void | ScaleNnet (BaseFloat scale, Nnet *nnet) |
Scales the nnet parameters and stats by this scale. More... | |
void | AddNnetComponents (const Nnet &src, const Vector< BaseFloat > &alphas, BaseFloat scale, Nnet *dest) |
Does *dest += alpha * src for updatable components (affects nnet parameters), and *dest += scale * src for other components (affects stored stats). More... | |
void | AddNnet (const Nnet &src, BaseFloat alpha, Nnet *dest) |
Does *dest += alpha * src (affects nnet parameters and stored stats). More... | |
int32 | NumParameters (const Nnet &src) |
Returns the total of the number of parameters in the updatable components of the nnet. More... | |
void | VectorizeNnet (const Nnet &src, VectorBase< BaseFloat > *params) |
Copies the nnet parameters to *params, whose dimension must be equal to NumParameters(src). More... | |
void | UnVectorizeNnet (const VectorBase< BaseFloat > ¶ms, Nnet *dest) |
Copies the parameters from params to *dest. More... | |
int32 | NumUpdatableComponents (const Nnet &dest) |
Returns the number of updatable components in the nnet. More... | |
void | FreezeNaturalGradient (bool freeze, Nnet *nnet) |
Controls if natural gradient will be updated. More... | |
void | ConvertRepeatedToBlockAffine (CompositeComponent *c_component) |
void | ConvertRepeatedToBlockAffine (Nnet *nnet) |
Convert all components of type RepeatedAffineComponent or NaturalGradientRepeatedAffineComponent to BlockAffineComponent in nnet. More... | |
std::string | NnetInfo (const Nnet &nnet) |
This function returns various info about the neural net. More... | |
void | SetDropoutProportion (BaseFloat dropout_proportion, Nnet *nnet) |
This function sets the dropout proportion in all dropout components to dropout_proportion value. More... | |
bool | HasBatchnorm (const Nnet &nnet) |
Returns true if nnet has at least one component of type BatchNormComponent. More... | |
void | ScaleBatchnormStats (BaseFloat batchnorm_stats_scale, Nnet *nnet) |
This function scales the batchorm stats of any batchnorm components (components of type BatchNormComponent) in 'nnet' by the scale 'batchnorm_stats_scale'. More... | |
void | RecomputeStats (const std::vector< NnetExample > &egs, Nnet *nnet) |
This function zeros the stored component-level stats in the nnet using ZeroComponentStats(), then recomputes them with the supplied egs. More... | |
void | SetBatchnormTestMode (bool test_mode, Nnet *nnet) |
This function affects only components of type BatchNormComponent. More... | |
void | SetDropoutTestMode (bool test_mode, Nnet *nnet) |
This function affects components of child-classes of RandomComponent. More... | |
void | ResetGenerators (Nnet *nnet) |
This function calls 'ResetGenerator()' on all components in 'nnet' that inherit from class RandomComponent. More... | |
void | FindOrphanComponents (const Nnet &nnet, std::vector< int32 > *components) |
This function finds a list of components that are never used, and outputs the integer comopnent indexes (you can use these to index nnet.GetComponentNames() to get their names). More... | |
void | FindOrphanNodes (const Nnet &nnet, std::vector< int32 > *nodes) |
This function finds a list of nodes that are never used to compute any output, and outputs the integer node indexes (you can use these to index nnet.GetNodeNames() to get their names). More... | |
void | ConstrainOrthonormalInternal (BaseFloat scale, CuMatrixBase< BaseFloat > *M) |
void | ConstrainOrthonormal (Nnet *nnet) |
This function, to be called after processing every minibatch, is responsible for enforcing the orthogonality constraint for any components of type LinearComponent or inheriting from AffineComponent that have the "orthonormal_constraint" value set. More... | |
void | ConsolidateMemory (Nnet *nnet) |
This just calls ConsolidateMemory() on all the components of the nnet. More... | |
void | ReduceRankOfComponents (const std::string component_name_pattern, int32 rank, Nnet *nnet) |
void | ReadEditConfig (std::istream &config_file, Nnet *nnet) |
ReadEditConfig() reads a file with a similar-looking format to the config file read by Nnet::ReadConfig(), but this consists of a sequence of operations to perform on an existing network, mostly modifying components. More... | |
bool | NnetIsRecurrent (const Nnet &nnet) |
Returns true if 'nnet' has some kind of recurrency. More... | |
void | CollapseModel (const CollapseModelConfig &config, Nnet *nnet) |
This function modifies the neural net for efficiency, in a way that suitable to be done in test time. More... | |
bool | UpdateNnetWithMaxChange (const Nnet &delta_nnet, BaseFloat max_param_change, BaseFloat max_change_scale, BaseFloat scale, Nnet *nnet, std::vector< int32 > *num_max_change_per_component_applied, int32 *num_max_change_global_applied) |
This function does the operation '*nnet += scale * delta_nnet', while respecting any max-parameter-change (max-param-change) specified in the updatable components, and also the global max-param-change specified as 'max_param_change'. More... | |
int32 | GetNumNvalues (const std::vector< NnetIo > &io_vec, bool exhaustive) |
This utility function can be used to obtain the number of distinct 'n' values in a training example. More... | |
void | ApplyL2Regularization (const Nnet &nnet, BaseFloat l2_regularize_scale, Nnet *delta_nnet) |
This function is used as part of the regular training workflow, prior to UpdateNnetWithMaxChange(). More... | |
bool | UpdateNnetWithMaxChange (const Nnet &delta_nnet, BaseFloat max_param_change, BaseFloat max_change_scale, BaseFloat scale, Nnet *nnet, MaxChangeStats *stats) |
BaseFloat | KlDivergence (const Vector< BaseFloat > &p, const Vector< BaseFloat > &q) |
void | PrintPriorDiagnostics (const Vector< BaseFloat > &old_priors, const Vector< BaseFloat > &new_priors) |
void | SetPriors (const TransitionModel &tmodel, const Vector< double > &transition_accs, double prior_floor, AmNnetSimple *am_nnet) |
double | ComputeObjf (bool batchnorm_test_mode, bool dropout_test_mode, const std::vector< NnetExample > &egs, const Nnet &nnet, NnetComputeProb *prob_computer) |
void | UpdateNnetMovingAverage (int32 num_models, const Nnet &nnet, Nnet *moving_average_nnet) |
void | RenameOutputs (const std::string &new_name, NnetExample *eg) |
void | ScaleSupervisionWeight (BaseFloat weight, NnetExample *eg) |
int32 | GetCount (double expected_count) |
bool | ContainsSingleExample (const NnetExample &eg, int32 *min_input_t, int32 *max_input_t, int32 *min_output_t, int32 *max_output_t) |
Returns true if the "eg" contains just a single example, meaning that all the "n" values in the indexes are zero, and the example has NnetIo members named both "input" and "output". More... | |
void | FilterExample (const NnetExample &eg, int32 min_input_t, int32 max_input_t, int32 min_output_t, int32 max_output_t, NnetExample *eg_out) |
This function filters the indexes (and associated feature rows) in a NnetExample, removing any index/row in an NnetIo named "input" with t < min_input_t or t > max_input_t and any index/row in an NnetIo named "output" with t < min_output_t or t > max_output_t. More... | |
bool | SelectFromExample (const NnetExample &eg, std::string frame_str, int32 left_context, int32 right_context, int32 frame_shift, NnetExample *eg_out) |
This function is responsible for possibly selecting one frame from multiple supervised frames, and reducing the left and right context as specified. More... | |
static bool | ProcessFile (const discriminative::SplitDiscriminativeSupervisionOptions &config, const TransitionModel &tmodel, const MatrixBase< BaseFloat > &feats, const MatrixBase< BaseFloat > *ivector_feats, int32 ivector_period, const discriminative::DiscriminativeSupervision &supervision, const std::string &utt_id, bool compress, UtteranceSplitter *utt_splitter, NnetDiscriminativeExampleWriter *example_writer) |
void | ApplyAffineTransform (MatrixBase< BaseFloat > &transform, int32 num_channels, MatrixBase< BaseFloat > *image, FillMode fill_mode) |
This function applies a geometric transformation 'transform' to the image. More... | |
void | PerturbImage (const ImageAugmentationConfig &config, MatrixBase< BaseFloat > *image) |
This function randomly modifies (perturbs) the image by applying different geometric transformations according to the options in 'config'. More... | |
void | PerturbImageInNnetExample (const ImageAugmentationConfig &config, NnetExample *eg) |
This function does image perturbation as directed by 'config' The example 'eg' is expected to contain a NnetIo member with the name 'input', representing an image. More... | |
static bool | ProcessFile (const GeneralMatrix &feats, const MatrixBase< BaseFloat > *ivector_feats, int32 ivector_period, const MatrixBase< BaseFloat > &targets, const std::string &utt_id, bool compress, int32 num_targets, int32 length_tolerance, UtteranceSplitter *utt_splitter, NnetExampleWriter *example_writer) |
static bool | ProcessFile (const GeneralMatrix &feats, const MatrixBase< BaseFloat > *ivector_feats, int32 ivector_period, const Posterior &pdf_post, const std::string &utt_id, bool compress, int32 num_pdfs, int32 length_tolerance, UtteranceSplitter *utt_splitter, NnetExampleWriter *example_writer) |
int32 | NumOutputIndexes (const NnetExample &eg) |
void | DivideIntoPieces (int32 a, int32 b, std::vector< int32 > *pieces) |
This function divides the number 'a' into 'b' pieces, such that the sum of the pieces equals 'a' and no two pieces differ by more than 1. More... | |
static void | RunNnetComputation (const MatrixBase< BaseFloat > &features, const Nnet &nnet, CachingOptimizingCompiler *compiler, Vector< BaseFloat > *xvector) |
static void | ProcessRangeFile (const std::string &range_rxfilename, unordered_map< std::string, std::vector< ChunkInfo *> > *utt_to_chunks) |
static void | WriteExamples (const MatrixBase< BaseFloat > &feats, const std::vector< ChunkInfo *> &chunks, const std::string &utt, bool compress, int32 num_pdfs, int32 *num_egs_written, std::vector< NnetExampleWriter *> *example_writers) |
Variables | |
static bool | computation_checker_warned_unused_input = false |
Checks that we never use variables before they are allocated or after they are deallocated, and some other checks that can be done from the MatrixAccesses. More... | |
const int | kNoTime = std::numeric_limits<int32>::min() |
Definition at line 115 of file nnet-common.h.
Definition at line 220 of file nnet-chain-example.h.
Definition at line 214 of file nnet-discriminative-example.h.
typedef TableWriter<KaldiObjectHolder<NnetExample > > NnetExampleWriter |
Definition at line 170 of file nnet-example.h.
typedef RandomAccessTableReader<KaldiObjectHolder<NnetChainExample > > RandomAccessNnetChainExampleReader |
Definition at line 222 of file nnet-chain-example.h.
typedef RandomAccessTableReader<KaldiObjectHolder<NnetDiscriminativeExample > > RandomAccessNnetDiscriminativeExampleReader |
Definition at line 216 of file nnet-discriminative-example.h.
Definition at line 172 of file nnet-example.h.
typedef SequentialTableReader<KaldiObjectHolder<NnetChainExample > > SequentialNnetChainExampleReader |
Definition at line 221 of file nnet-chain-example.h.
typedef SequentialTableReader<KaldiObjectHolder<NnetDiscriminativeExample > > SequentialNnetDiscriminativeExampleReader |
Definition at line 215 of file nnet-discriminative-example.h.
Definition at line 171 of file nnet-example.h.
enum AccessType |
Enumerator | |
---|---|
kReadAccess | |
kWriteAccess | |
kReadWriteAccess |
Definition at line 75 of file nnet-analyze.h.
enum CommandType |
CommandType is an enum that describes the category of the command used in the NnetComputation.
We declare it outside that class because it's so frequently used and we got tired of typing NnetComputation:: everywhere. We document the commands here. Note: for operations that naturally need to operate on entire matrices (i.e. allocation commands and input and output commands), we use the submatrix indexes of them, which turns out to be more convenient for optimization; but these submatrix indexes must refer to the whole of a matrix.
Definition at line 288 of file nnet-computation.h.
enum ComponentProperties |
Definition at line 37 of file nnet-component-itf.h.
enum FillMode |
enum NodeType |
Enumerator | |
---|---|
kInput | |
kDescriptor | |
kComponent | |
kDimRange | |
kNone |
Definition at line 55 of file nnet-nnet.h.
enum ObjectiveType |
This enum is for a kind of annotation we associate with output nodes of the network; it's for the convenience of calling code so that if the objective is one of a few standard types, we can compute it directly and know how to interpret the supervision labels.
However, the core of the framework never makes use of the objective types, other than making them available to calling code which then supplies the derivatives.
Enumerator | |
---|---|
kLinear | |
kQuadratic |
Definition at line 52 of file nnet-nnet.h.
Does *dest += alpha * src (affects nnet parameters and stored stats).
Definition at line 349 of file nnet-utils.cc.
References Component::Add(), Nnet::GetComponent(), KALDI_ERR, and Nnet::NumComponents().
Referenced by main(), kaldi::ReadModels(), NnetDiscriminativeTrainer::Train(), and UpdateNnetMovingAverage().
void AddNnetComponents | ( | const Nnet & | src, |
const Vector< BaseFloat > & | alphas, | ||
BaseFloat | scale, | ||
Nnet * | dest | ||
) |
Does *dest += alpha * src for updatable components (affects nnet parameters), and *dest += scale * src for other components (affects stored stats).
Here, alphas is a vector of size equal to the number of updatable components
Definition at line 322 of file nnet-utils.cc.
References Component::Add(), VectorBase< Real >::Dim(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), and Component::Properties().
Referenced by UpdateNnetWithMaxChange().
void kaldi::nnet3::AddTimeOffsetToComputationRequest | ( | int32 | t_offset, |
ComputationRequest * | request | ||
) |
Definition at line 235 of file nnet-compile-looped.cc.
References rnnlm::i, ComputationRequest::inputs, rnnlm::j, and ComputationRequest::outputs.
Referenced by ExtrapolateComputationRequest().
void AppendCindexes | ( | int32 | node, |
const std::vector< Index > & | indexes, | ||
std::vector< Cindex > * | out | ||
) |
Appends to 'out' the pairs (node, indexes[0]), (node, indexes[1]), ...
Definition at line 1384 of file nnet-compile.cc.
References rnnlm::i.
Referenced by Compiler::OutputDebugInfo().
void kaldi::nnet3::ApplyAffineTransform | ( | MatrixBase< BaseFloat > & | transform, |
int32 | num_channels, | ||
MatrixBase< BaseFloat > * | image, | ||
FillMode | fill_mode | ||
) |
This function applies a geometric transformation 'transform' to the image.
Reference: Digital Image Processing book by Gonzalez and Woods.
[in] | transform | The 3x3 geometric transformation matrix to apply. |
[in] | num_channels | Number of channels (i.e. colors) of the image |
[in,out] | image | The image matrix to be modified. image->NumRows() is the width (number of x values) in the image; image->NumCols() is the height times number of channels (channel varies the fastest). |
Definition at line 110 of file nnet3-egs-augment-image.cc.
References KALDI_ASSERT, kNearest, ImageAugmentationConfig::num_channels, MatrixBase< Real >::NumCols(), and MatrixBase< Real >::NumRows().
Referenced by PerturbImage().
This function is used as part of the regular training workflow, prior to UpdateNnetWithMaxChange().
For each updatable component c in the neural net, suppose it has a l2-regularization constant alpha set at the component level (see UpdatableComponent::L2Regularization()), and a learning-rate eta, then this function does (and this is not real code):
delta_nnet->c -= 2.0 * l2_regularize_scale * alpha * eta * nnet.c
The factor of -1.0 comes from the fact that we are maximizing, and we'd add the l2 regularization term (of the form ||||_2^2, i.e. squared l2 norm) in the objective function with negative sign; the factor of 2.0 comes from the derivative of the squared parameters. The factor 'l2_regularize_scale' is provided to this function, see below for an explanation.
Note: the way we do it is a little bit approximate, due to the interaction with natural gradient. The issue is that the regular gradients are multiplied by the inverse of the approximated, smoothed and factored inverse Fisher matrix, but the l2 gradients are not. This means that what we're optimizing is not exactly the (regular objective plus the L2 term)– we could view it as optimizing (regular objective plus the l2 term times the Fisher matrix)– with the proviso that the Fisher matrix has been scaled in such a way that the amount of parameter change is not affected, so this is not an issue of affecting the overall strength of l2, just an issue of the direction-wise weighting. In effect, the l2 term will be larger, relative to the gradient contribution, in directions where the Fisher matrix is large. This is probably not ideal– but it's hard to judge without experiments. Anyway the l2 effect is small enough, and the Fisher matrix sufficiently smoothed with the identity, that I doubt this makes much of a difference.
[in] | nnet | The neural net that is being trained; expected to be different from delta_nnet |
[in] | l2_regularize_scale | A scale on the l2 regularization. Usually this will be equal to the number of distinct examples (e.g. the number of chunks of speech– more precisely, the number of distinct 'n' values) in the minibatch, but this is multiplied by a configuration value –l2-regularize-factor passed in from the command line. The reason for making l2 proportional to the number of elements in the minibatch is that we add the parameter gradients over the minibatch (we don't average), so multiplying the l2 factor by the number of elements in the minibatch is necessary to make the amount of l2 vs. gradient contribution stay the same when we vary the minibatch size. The –l2-regularize-factor option is provided so that the calling script can correct for the effects of parallelization via model-averaging (we'd normally set this to 1/num-parallel-jobs). |
[out] | delta_nnet | The neural net containing the parameter updates; this is a copy of 'nnet' that is used for purposes of momentum and applying max-change values. This is what this code adds to. |
Definition at line 2244 of file nnet-utils.cc.
References Component::Add(), Nnet::GetComponent(), KALDI_ASSERT, kUpdatableComponent, UpdatableComponent::L2Regularization(), UpdatableComponent::LearningRate(), Nnet::NumComponents(), and Component::Properties().
Referenced by CollapseModelConfig::CollapseModelConfig(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), and NnetTrainer::TrainInternalBackstitch().
bool kaldi::nnet3::AssertGraphEqual | ( | const std::vector< std::vector< int32 > > & | graph1, |
const std::vector< std::vector< int32 > > & | graph2 | ||
) |
Definition at line 26 of file nnet-graph-test.cc.
References rnnlm::i, and rnnlm::j.
Referenced by UnitTestComputeGraphTranspose(), UnitTestFindSccs(), and UnitTestMakeSccGraph().
bool kaldi::nnet3::AssertVectorEqual | ( | const std::vector< int32 > & | vec1, |
const std::vector< int32 > & | vec2 | ||
) |
Definition at line 38 of file nnet-graph-test.cc.
References rnnlm::i.
Referenced by UnitTestComputeTopSortOrder(), and UnitTestComputeTopSortOrder2().
void kaldi::nnet3::BuildTestGraph | ( | std::vector< std::vector< int32 > > * | graph | ) |
Definition at line 47 of file nnet-graph-test.cc.
References KALDI_ASSERT.
Referenced by UnitTestComputeGraphTranspose(), UnitTestFindSccs(), and UnitTestMakeSccGraph().
void kaldi::nnet3::BuildTestGraphTranspose | ( | std::vector< std::vector< int32 > > * | graph | ) |
Definition at line 72 of file nnet-graph-test.cc.
References KALDI_ASSERT.
Referenced by UnitTestComputeGraphTranspose().
void kaldi::nnet3::BuildTestSccGraph | ( | std::vector< std::vector< int32 > > * | scc_graph | ) |
Definition at line 114 of file nnet-graph-test.cc.
References KALDI_ASSERT.
Referenced by UnitTestComputeTopSortOrder(), and UnitTestMakeSccGraph().
void kaldi::nnet3::BuildTestSccs | ( | std::vector< std::vector< int32 > > * | sccs | ) |
Definition at line 97 of file nnet-graph-test.cc.
References KALDI_ASSERT.
Referenced by UnitTestFindSccs(), and UnitTestMakeSccGraph().
void kaldi::nnet3::BuildTestTopSortOrder | ( | std::vector< int32 > * | node_to_order | ) |
Definition at line 131 of file nnet-graph-test.cc.
References KALDI_ASSERT.
Referenced by UnitTestComputeTopSortOrder().
void CheckComputation | ( | const Nnet & | nnet, |
const NnetComputation & | computation, | ||
bool | check_rewrite = false |
||
) |
This is a convenience interface for class ComputationChecker.
Call it with check_rewrite = true only if the computation is pre-optimization. If the computation is an 'online' computation, this function treats it specially.
Definition at line 1145 of file nnet-analyze.cc.
References ComputationChecker::Check(), CheckComputationOptions::check_rewrite, CheckComputationOnline(), NnetComputation::commands, KALDI_ERR, kGotoLabel, and NnetComputation::Print().
Referenced by CachingOptimizingCompiler::CompileViaShortcut(), and Optimize().
|
static |
Definition at line 1118 of file nnet-analyze.cc.
References ComputationChecker::Check(), CheckComputationOptions::check_rewrite, CheckComputationOptions::check_unused_variables, NnetComputation::commands, KALDI_ASSERT, kDeallocMatrix, kGotoLabel, kSwapMatrix, and kaldi::swap().
Referenced by CheckComputation().
bool kaldi::nnet3::CheckStringsApproxEqual | ( | const std::string & | a, |
const std::string & | b, | ||
int32 | tolerance = 3 |
||
) |
Definition at line 39 of file nnet-component-test.cc.
References KALDI_WARN, and kaldi::StringsApproxEqual().
Referenced by TestNnetComponentAddScale(), TestNnetComponentIo(), TestNnetComponentUpdatable(), and TestNnetComponentVectorizeUnVectorize().
void CollapseModel | ( | const CollapseModelConfig & | config, |
Nnet * | nnet | ||
) |
This function modifies the neural net for efficiency, in a way that suitable to be done in test time.
For example, it tries to get rid of dropout, batchnorm and fixed-scale components, and to collapse subsequent affine components if doing so won't hurt speed.
Definition at line 2100 of file nnet-utils.cc.
References ModelCollapser::Collapse().
Referenced by CollapseModelConfig::CollapseModelConfig(), main(), and UnitTestNnetCompute().
void CompileLooped | ( | const Nnet & | nnet, |
const NnetOptimizeOptions & | optimize_opts, | ||
const ComputationRequest & | request1, | ||
const ComputationRequest & | request2, | ||
const ComputationRequest & | request3, | ||
NnetComputation * | computation | ||
) |
CompileLooped() provides an internal interface for 'looped' computation.
It's usable for inference only (not training), meaning that backprop is not supported (for now, at least). CompileLooped() allows you to do the neural net computation for small chunks with increasing 't' values, and naturally cache the intermediate activations (rather than recomputing them every time you see new input data).
This function does both compilation and optimization, so it's like a combination of Compiler::CreateComputation() [nnet-compile.h] and Optimize() [nnet-optimize.h].
You provide 3 computation requests. request1 is the first computation request of an utterance (or other type of segment) that contains any required extra left context in the input. request2 and request3 are the second and third computation request, and must have exactly the same structure, except for a fixed time offset (change in 't' index) between them. This will be extrapolated to an infinite sequence of further requests (request4, request5, etc.). In practice the way it's done is that we extrapolate to a small finite number of requests (like 10), and then attempt to identify a common structure in the computation where, after processing, as an example, the 3nd computation request, the active variables can be identified with those present at, say, the 7th computation request, and we then cut and splice the computation together at this points, like making a tape loop, by adding a goto statement that jumps from the end of the 7th computation request to the end of the 3rd computation request. We also have to identify the variables with each other (merge variables).
That's done in the optimization code.
Definition at line 329 of file nnet-compile-looped.cc.
References CompileLoopedInternal(), Timer::Elapsed(), KALDI_ERR, KALDI_LOG, and KALDI_VLOG.
Referenced by DecodableNnetSimpleLoopedInfo::Init(), and UnitTestNnetCompileLooped().
|
static |
Definition at line 284 of file nnet-compile-looped.cc.
References NnetComputation::commands, Compiler::CreateComputation(), ExtrapolateComputationRequest(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, kGotoLabel, MaxOutputTimeInRequest(), Optimize(), NnetOptimizeOptions::optimize_looped_computation, and ComputationRequest::Print().
Referenced by CompileLooped().
void ComponentDotProducts | ( | const Nnet & | nnet1, |
const Nnet & | nnet2, | ||
VectorBase< BaseFloat > * | dot_prod | ||
) |
Returns dot products between two networks of the same structure (calls the DotProduct functions of the Updatable components and fill in the output vector).
Definition at line 211 of file nnet-utils.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), KALDI_ASSERT, kUpdatableComponent, Nnet::NumComponents(), and Component::Properties().
Referenced by main().
void ComputeAccuracy | ( | const GeneralMatrix & | supervision, |
const CuMatrixBase< BaseFloat > & | nnet_output, | ||
BaseFloat * | tot_weight, | ||
BaseFloat * | tot_accuracy, | ||
VectorBase< BaseFloat > * | tot_weight_vec = NULL , |
||
VectorBase< BaseFloat > * | tot_accuracy_vec = NULL |
||
) |
This function computes the frame accuracy for this minibatch.
It interprets the supervision information in "supervision" as labels or soft labels; it picks the maximum element in each row and treats that as the label for purposes of computing the accuracy (in situations where you would care about the accuracy, there will normally be just one nonzero label). The hypothesized labels are computed by taking the neural net output (supplied as a CuMatrix), and finding the maximum element in each row. See also the function ComputeObjectiveFunction, declared in nnet-training.h.
[in] | supervision | The supervision information (no elements may be negative); only the maximum in each row matters (although we expect that usually there will be just one nonzero element in each row); and the sum of each row is interpreted as a weighting factor (although we expect that this sum will usually be one). |
[in] | nnet_output | The neural net output must have the same dimensions as the supervision. Only the index of the maximum value in each row matters. Ties will be broken in an unspecified way. |
[out] | tot_weight | The sum of the values in the supervision matrix |
[out] | tot_accuracy | The total accuracy, equal to the sum over all row indexes r such that the maximum column index of row r of supervision and nnet_output is the same, of the sum of the r'th row of supervision (i.e. the row's weight). |
[out] | tot_weight_vec | If non-NULL, we write to this location the counts per-class in the supervision matrix. This is expected to have the same dimension as the corresponding output in the network. |
[out] | tot_accuracy_vec | If non-NULL, we write to this location the accuracy per-class. For index j, the value is equal to the sum over all row indexes r such that the maximum column index of row r of supervision is j and nnet_output is also j, of the sum of the r'th row of supervision (i.e. the row's weight) |
Definition at line 206 of file nnet-diagnostics.cc.
References CuArrayBase< T >::CopyToVec(), VectorBase< Real >::Dim(), CuMatrixBase< Real >::FindRowMaxId(), GeneralMatrix::GetFullMatrix(), GeneralMatrix::GetMatrix(), GeneralMatrix::GetSparseMatrix(), KALDI_ASSERT, KALDI_ERR, kaldi::kCompressedMatrix, kaldi::kFullMatrix, kaldi::kSparseMatrix, SparseVector< Real >::Max(), VectorBase< Real >::Max(), CuMatrixBase< Real >::NumCols(), GeneralMatrix::NumCols(), CuMatrixBase< Real >::NumRows(), GeneralMatrix::NumRows(), SparseMatrix< Real >::Row(), VectorBase< Real >::Set(), SparseVector< Real >::Sum(), VectorBase< Real >::Sum(), and GeneralMatrix::Type().
Referenced by NnetComputeProb::ProcessOutputs().
void ComputeCommandAttributes | ( | const Nnet & | nnet, |
const NnetComputation & | computation, | ||
const ComputationVariables & | vars, | ||
std::vector< CommandAttributes > * | attributes | ||
) |
Definition at line 284 of file nnet-analyze.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::arg4, NnetComputation::Command::arg5, NnetComputation::Command::arg6, NnetComputation::Command::command_type, NnetComputation::commands, count, Nnet::GetComponent(), CommandAttributes::has_side_effects, rnnlm::i, NnetComputation::indexes, NnetComputation::indexes_multi, IndexesMultiToSubmatrixIndexes(), kAcceptInput, kAddRowRanges, kAddRows, kAddRowsMulti, kAddToRowsMulti, KALDI_ERR, kAllocMatrix, kBackprop, kBackpropAdds, kBackpropNoModelUpdate, kCompressMatrix, kCopyRows, kCopyRowsMulti, kCopyToRowsMulti, kDeallocMatrix, kDecompressMatrix, kGotoLabel, kMatrixAdd, kMatrixCopy, kNoOperation, kNoOperationLabel, kNoOperationMarker, kNoOperationPermanent, kPropagate, kPropagateAdds, kProvideOutput, kReadAccess, kReadWriteAccess, kSetConst, kSwapMatrix, kUpdatableComponent, kWriteAccess, CommandAttributes::matrices_read, CommandAttributes::matrices_written, Component::Properties(), ComputationVariables::RecordAccessForSubmatrix(), kaldi::SortAndUniq(), CommandAttributes::submatrices_read, CommandAttributes::submatrices_written, CommandAttributes::variables_read, and CommandAttributes::variables_written.
Referenced by NnetComputer::Init(), Analyzer::Init(), and MoveSizingCommands().
|
static |
Definition at line 328 of file nnet-optimize.cc.
References kaldi::CopyVectorToSet(), rnnlm::d, and KALDI_PARANOID_ASSERT.
Referenced by RemoveUnnecessaryAllocation().
void kaldi::nnet3::ComputeComputationGraph | ( | const Nnet & | nnet, |
const ComputationRequest & | request, | ||
ComputationGraph * | graph | ||
) |
Definition at line 1152 of file nnet-computation-graph.cc.
References kaldi::nnet3::computation_graph::AddInputToGraph(), kaldi::nnet3::computation_graph::AddOutputToGraph(), ComputationGraph::cindexes, NetworkNode::component_index, ComputationGraph::dependencies, NetworkNode::descriptor, ComputationGraph::GetCindexId(), Nnet::GetComponent(), Descriptor::GetDependencies(), Component::GetInputIndexes(), Nnet::GetNode(), rnnlm::i, ComputationGraph::is_input, KALDI_ASSERT, KALDI_ERR, kComponent, kDescriptor, kDimRange, kInput, ComputationRequest::misc_info, rnnlm::n, NetworkNode::node_index, NetworkNode::node_type, kaldi::SortAndUniq(), and NetworkNode::u.
void ComputeComputationPhases | ( | const Nnet & | nnet, |
const ComputationGraph & | computation_graph, | ||
std::vector< std::vector< std::vector< int32 > > > * | phases_per_segment | ||
) |
This function divides a computation into 'phases', where a 'phase' is a collection of cindexes which can (as far as the computation graph is concerned) all be computed at the same time, and depend only on cindexes previously computed in earlier phases.
So the phases are an ordering of the Cindexes in the computation, but an ordering that depends on graph-theoretic considerations only, and not practical concerns like whether the cindexes belong to the same node [for that, see the notion of steps].
[in] | nnet | The neural network this computation is for |
[in] | graph | The computation graph that we're computing phases for. |
[out] | phases_per_segment | The phases, listed separately for each segment of the computation [there will be just one segment in the normal case, more in the online-recognition case]. Consider just one segment for now. Suppose the computation can be completed in 20 phases, then (*phases)[0].size() will be 20 at exit, and (*phases)[0][0] will be a sorted list of cindex_ids. that belong to the first phase, and so on. (Remember, a cindex_id is an index into graph->cindexes; it compactly identifies a cindex.) The sets represented by the int32's in 'phases_per_segment' will be disjoint and will cover all elements in [0 .. computation.cindexes.size() - 1]. |
Note: we assume you have called PruneComputationGraph() before this function. Even so, this function will be crash if the computation cannot actually be computed– there are some mal-formed computations where you can build the computation graph but not the ordering of cindexes because there are dependencies forward and backward in time that intertwine.
Definition at line 1406 of file nnet-computation-graph.cc.
References ComputationGraph::cindexes, ComputeComputationPhasesForEpoch(), kaldi::nnet3::computation_graph::ComputeDependenciesSubset(), kaldi::nnet3::computation_graph::ComputeEpochInfo(), ComputeGraphTranspose(), KALDI_ASSERT, ComputationGraph::segment_ends, and SumVectorSizes().
Referenced by Compiler::CreateComputation().
|
inlinestatic |
Definition at line 1307 of file nnet-computation-graph.cc.
References rnnlm::d, KALDI_ASSERT, KALDI_ERR, and kaldi::SortAndUniq().
Referenced by ComputeComputationPhases().
void ComputeExampleComputationRequestSimple | ( | const Nnet & | nnet, |
ComputationRequest * | request, | ||
std::vector< Matrix< BaseFloat > > * | inputs | ||
) |
This function computes an example computation request, for testing purposes.
The "Simple" in the name means that it currently only supports neural nets that satisfy IsSimple(nnet) (defined in nnet-utils.h). If there are 2 inputs, the "input" will be first, followed by "ivector".
In order to expand the range of things you can test with this (mainly to stop crashes with statistics-pooling/statistics-extraction components), this function always generates computation-requests where at least 3 successive frames of input are requested.
Definition at line 1338 of file nnet-test-utils.cc.
References ComputeSimpleNnetContext(), Nnet::InputDim(), ComputationRequest::inputs, IsSimpleNnet(), KALDI_ASSERT, rnnlm::n, ComputationRequest::need_model_derivative, ComputationRequest::outputs, kaldi::Rand(), and ComputationRequest::store_component_stats.
Referenced by NnetGenerationOptions::NnetGenerationOptions(), UnitTestNnetAnalyze(), UnitTestNnetCompile(), UnitTestNnetCompileMulti(), UnitTestNnetCompute(), UnitTestNnetInputDerivatives(), UnitTestNnetModelDerivatives(), and UnitTestNnetOptimizeWithOptions().
void ComputeGraphTranspose | ( | const std::vector< std::vector< int32 > > & | graph, |
std::vector< std::vector< int32 > > * | graph_transpose | ||
) |
Outputs a graph in which the order of arcs is reversed.
Definition at line 63 of file nnet-graph.cc.
References rnnlm::n.
Referenced by ComputeComputationPhases(), FindOrphanNodes(), and UnitTestComputeGraphTranspose().
void ComputeMatrixAccesses | ( | const Nnet & | nnet, |
const NnetComputation & | computation, | ||
const ComputationVariables & | variables, | ||
const std::vector< CommandAttributes > & | command_attributes, | ||
std::vector< MatrixAccesses > * | matrix_accesses | ||
) |
This function organizes information in the CommandAttributes in a way that is convenient to access per matrix.
See the declaration of struct MatrixAccesses for the output format; the output "matrix_accesses" is indexed by matrix index (the same index as computation.matrices).
Definition at line 467 of file nnet-analyze.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::command_type, NnetComputation::commands, kaldi::IsSortedAndUniq(), NnetComputation::IsWholeMatrix(), kAcceptInput, KALDI_ASSERT, KALDI_ERR, kAllocMatrix, kDeallocMatrix, kProvideOutput, kReadAccess, kReadWriteAccess, kSwapMatrix, kWriteAccess, NnetComputation::matrices, CommandAttributes::matrices_read, CommandAttributes::matrices_written, kaldi::SortAndUniq(), and NnetComputation::submatrices.
Referenced by Analyzer::Init(), MatrixAccesses::MatrixAccesses(), and MoveSizingCommands().
void ComputeMatrixToSubmatrix | ( | const NnetComputation & | computation, |
std::vector< std::vector< int32 > > * | mat_to_submat | ||
) |
This function computes a vector 'mat_to_submat', indexed by matrix index, such that (*mat_to_submat)[m] is a list of all the submatrix indexes that refer to matrix m.
Note, (*mat_to_submat)[0] will be the empty vector.
Definition at line 1166 of file nnet-analyze.cc.
References KALDI_ASSERT, NnetComputation::matrices, and NnetComputation::submatrices.
Referenced by VariableMergingOptimizer::VariableMergingOptimizer().
void kaldi::nnet3::ComputeMinAndMaxTimes | ( | const std::vector< Index > & | indexes, |
int32 * | min_t, | ||
int32 * | max_t | ||
) |
Definition at line 31 of file nnet-derivative-test.cc.
References KALDI_ASSERT, and rnnlm::n.
Referenced by SetDerivTimesOptions().
This function computes the order in which we need to compute each node in the graph, where each node-index n maps to an epoch-index t = 0, 1, ...
that says when we should compute it. Nodes that are part of a strongly connected component (SCC) will all be computed at the same time, but any two nodes that are not part of an SCC will have different epoch-index, and these epoch-indexes will be such that a node computed at a larger epoch-index may depend on a node computed at a smaller epoch-index, but not vice versa.
Internally it calls NnetToDirectedGraph, FindSccs, MakeSccGraph and ComputeTopSortOrder.
Definition at line 265 of file nnet-graph.cc.
References ComputeTopSortOrder(), FindSccs(), kaldi::GetVerboseLevel(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_VLOG, MakeSccGraph(), NnetToDirectedGraph(), and PrintGraphToString().
Referenced by kaldi::nnet3::computation_graph::ComputeEpochInfo().
void ComputeObjectiveFunction | ( | const GeneralMatrix & | supervision, |
ObjectiveType | objective_type, | ||
const std::string & | output_name, | ||
bool | supply_deriv, | ||
NnetComputer * | computer, | ||
BaseFloat * | tot_weight, | ||
BaseFloat * | tot_objf | ||
) |
This function computes the objective function, and if supply_deriv = true, supplies its derivative to the NnetComputation object.
See also the function ComputeAccuracy(), declared in nnet-diagnostics.h.
[in] | supervision | A GeneralMatrix, typically derived from a NnetExample, containing the supervision posteriors or features. |
[in] | objective_type | The objective function type: kLinear = output * supervision, or kQuadratic = -0.5 * (output - supervision)^2. kLinear is used for softmax objectives; the network contains a LogSoftmax layer which correctly normalizes its output. |
[in] | output_name | The name of the output node (e.g. "output"), used to look up the output in the NnetComputer object. |
[in] | supply_deriv | If this is true, this function will compute the derivative of the objective function and supply it to the network using the function NnetComputer::AcceptOutputDeriv |
[in,out] | computer | The NnetComputer object, from which we get the output using GetOutput and to which we may supply the derivatives using AcceptOutputDeriv. |
[out] | tot_weight | The total weight of the training examples. In the kLinear case, this is the sum of the supervision matrix; in the kQuadratic case, it is the number of rows of the supervision matrix. In order to make it possible to weight samples with quadratic objective functions, we may at some point make it possible for the supervision matrix to have an extra column containing weights. At the moment, this is not supported. |
[out] | tot_objf | The total objective function; divide this by the tot_weight to get the normalized objective function. |
Definition at line 339 of file nnet-training.cc.
References NnetComputer::AcceptInput(), CuMatrixBase< Real >::CopyFromGeneralMat(), CuSparseMatrix< Real >::CopyToMat(), GeneralMatrix::GetFullMatrix(), GeneralMatrix::GetMatrix(), NnetComputer::GetOutput(), GeneralMatrix::GetSparseMatrix(), KALDI_ERR, kaldi::kCompressedMatrix, kaldi::kFullMatrix, kLinear, kQuadratic, kaldi::kSparseMatrix, kaldi::kTrans, kaldi::kUndefined, CuMatrixBase< Real >::NumCols(), GeneralMatrix::NumCols(), CuMatrixBase< Real >::NumRows(), GeneralMatrix::NumRows(), CuSparseMatrix< Real >::Sum(), CuMatrixBase< Real >::Sum(), CuMatrix< Real >::Swap(), kaldi::TraceMatMat(), kaldi::TraceMatSmat(), and GeneralMatrix::Type().
Referenced by NnetComputeProb::ProcessOutputs(), and NnetTrainer::ProcessOutputs().
double kaldi::nnet3::ComputeObjf | ( | bool | batchnorm_test_mode, |
bool | dropout_test_mode, | ||
const std::vector< NnetExample > & | egs, | ||
const Nnet & | nnet, | ||
NnetComputeProb * | prob_computer | ||
) |
Definition at line 35 of file nnet3-combine.cc.
References NnetComputeProb::Compute(), NnetComputeProb::GetTotalObjective(), KALDI_ASSERT, NnetComputeProb::Reset(), SetBatchnormTestMode(), and SetDropoutTestMode().
Referenced by main().
ComputeSimpleNnetContext computes the left-context and right-context of a nnet.
The nnet must satisfy IsSimpleNnet(nnet).
It does this by constructing a ComputationRequest with a certain number of inputs available, outputs can be computed.. It does the same after shifting the time index of the output to all values 0, 1, ... n-1, where n is the output of nnet.Modulus(). Then it returns the largest left context and the largest right context that it infers from any of these computation requests.
Definition at line 146 of file nnet-utils.cc.
References ComputeSimpleNnetContextForShift(), IsSimpleNnet(), KALDI_ASSERT, KALDI_ERR, and Nnet::Modulus().
Referenced by ComputeExampleComputationRequestSimple(), CreateLoopedComputationRequestSimple(), CachingOptimizingCompiler::GetSimpleNnetContext(), Nnet::Info(), DecodableNnetSimpleLoopedInfo::Init(), main(), NnetBatchComputer::NnetBatchComputer(), NnetInfo(), AmNnetSimple::SetContext(), and UnitTestNnetContext().
|
static |
Definition at line 92 of file nnet-utils.cc.
References EvaluateComputationRequest(), Nnet::GetNodeIndex(), IoSpecification::indexes, ComputationRequest::inputs, KALDI_ASSERT, Nnet::Modulus(), rnnlm::n, IoSpecification::name, and ComputationRequest::outputs.
Referenced by ComputeSimpleNnetContext().
void ComputeTopSortOrder | ( | const std::vector< std::vector< int32 > > & | graph, |
std::vector< int32 > * | node_to_order | ||
) |
Given an acyclic graph (where each std::vector<int32> is a list of destination-nodes of arcs coming from the current node), compute a topological ordering of the graph nodes.
The output format is that node_to_order[n] contains an integer t = 0, 1, ... which is the order of node n in a topological sorting. node_to_order should contain some permutation of the numbers 0 ... graph.size() - 1. This function should crash if the graph contains cycles.
Definition at line 223 of file nnet-graph.cc.
References ComputeTopSortOrderRecursive(), rnnlm::i, and KALDI_ASSERT.
Referenced by ComputeNnetComputationEpochs(), UnitTestComputeTopSortOrder(), and UnitTestComputeTopSortOrder2().
void kaldi::nnet3::ComputeTopSortOrderRecursive | ( | int32 | node, |
const std::vector< std::vector< int32 > > & | graph, | ||
std::vector< bool > * | cycle_detector, | ||
std::vector< bool > * | is_visited, | ||
std::vector< int32 > * | reversed_orders | ||
) |
Definition at line 196 of file nnet-graph.cc.
References rnnlm::i, KALDI_ASSERT, and KALDI_ERR.
Referenced by ComputeTopSortOrder().
void ComputeVariableAccesses | ( | const ComputationVariables & | variables, |
const std::vector< CommandAttributes > & | command_attributes, | ||
std::vector< std::vector< Access > > * | variable_accesses | ||
) |
After the command-level attributes have been computed, this function organizes them per variable (see class ComputationVariables for how a variable is defined; it is part of a matrix).
[in] | variables | The definition of variables for this computation |
[in] | command_attributes | A vector of attributes, one per command, as obtained from ComputeCommandAttributes(). |
[out] | variable_accesses | The output will have a size equal to the number of variables, and each element will be a vector of accesses, sorted by command index; each command will only be listed once in this vector. |
Definition at line 421 of file nnet-analyze.cc.
References kaldi::IsSortedAndUniq(), KALDI_ASSERT, kReadAccess, kReadWriteAccess, kWriteAccess, ComputationVariables::NumVariables(), kaldi::SortAndUniq(), CommandAttributes::variables_read, and CommandAttributes::variables_written.
Referenced by Analyzer::Init(), MoveSizingCommands(), and Access::operator<().
void ConsolidateIoOperations | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This optimization puts the input operations (kAcceptInput) and output operations (kProvideOutput) at the very beginning or end of segments of computation, respectively.
This is actually necessary for computations to be run easily, because if these commands were interspersed with the regular commands, you'd have to call computer.Run() between the individual AcceptInput() and GetOutput() function calls.
Definition at line 869 of file nnet-optimize.cc.
References NnetComputation::commands, kAcceptInput, KALDI_ASSERT, kNoOperationMarker, kProvideOutput, and SplitComputationIntoSegments().
Referenced by Compiler::CreateComputation(), and Optimize().
void ConsolidateMemory | ( | Nnet * | nnet | ) |
This just calls ConsolidateMemory() on all the components of the nnet.
This is called by the training code after processing the first minibatch. On some components this will do nothing; on some components it will reallocate certain quantities that have been allocated during training (mostly the contents of NaturalGradientOnline objects, and stats for NonlinearComponents) so that they can be put into low memory. This will tend to minimize memory fragmentation. Read comments in ../cudamatrix/cu-allocator.h for more explanation.
Definition at line 1147 of file nnet-utils.cc.
References Component::ConsolidateMemory(), Nnet::GetComponent(), kaldi::GetVerboseLevel(), KALDI_VLOG, and Nnet::NumComponents().
Referenced by CollapseModelConfig::CollapseModelConfig(), NonlinearComponent::OutputDim(), NnetChainTrainer::Train(), and NnetTrainer::Train().
void ConsolidateModelUpdate | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This optimization consolidates the model-update part of backprop commands, for components in (e.g.) recurrent networks that need to have many separate backprop commands, into more efficient single commands operating on consolidated data in larger matrices.
This consolidates the model-update parts of the backprop into larger operations (applicable mostly to recurrent setups)– internally it uses class ModelUpdateConsolidator.
This is useful for recurrent networks. The resulting computation separates the backprop for data-derivatives from the model-update part of backprop.
Will fail if called a second time.
Definition at line 1551 of file nnet-optimize-utils.cc.
References ModelUpdateConsolidator::ConsolidateModelUpdate(), and NnetComputation::need_model_derivative.
Referenced by Optimize().
void ConstrainOrthonormal | ( | Nnet * | nnet | ) |
This function, to be called after processing every minibatch, is responsible for enforcing the orthogonality constraint for any components of type LinearComponent or inheriting from AffineComponent that have the "orthonormal_constraint" value set.
This function, to be called after processing every minibatch, is responsible for enforcing the orthogonality constraint for any components of type LinearComponent or inheriting from AffineComponent that have the "orthonormal-constraint" value set to a nonzero value.
Technically what we are doing is constraining the parameter matrix M to be a "semi-orthogonal" matrix times a constant alpha. That is: if num-rows > num-cols, this amounts to asserting that M M^T == alpha^2 I; otherwise, that M^T M == alpha^2 I.
If, for a particular component, orthonormal-constraint > 0.0, then that value becomes the "alpha" mentioned above. If orthonormal-constraint == 0.0, then nothing is done. If orthonormal-constraint < 0.0, then it's like letting alpha "float", i.e. we try to make M closer to (any constant alpha) times a semi-orthogonal matrix.
In order to make it efficient on GPU, it doesn't make it completely orthonormal, it just makes it closer to being orthonormal (times the 'orthonormal_constraint' value). Over multiple iterations this rapidly makes it almost exactly orthonormal.
See http://www.danielpovey.com/files/2018_interspeech_tdnnf.pdf
Definition at line 1108 of file nnet-utils.cc.
References ConstrainOrthonormalInternal(), CuMatrixBase< Real >::CopyFromMat(), Nnet::GetComponent(), kaldi::kTrans, AffineComponent::LinearParams(), TdnnComponent::LinearParams(), CuMatrixBase< Real >::NumCols(), Nnet::NumComponents(), CuMatrixBase< Real >::NumRows(), AffineComponent::OrthonormalConstraint(), TdnnComponent::OrthonormalConstraint(), LinearComponent::OrthonormalConstraint(), LinearComponent::Params(), and kaldi::RandInt().
Referenced by CollapseModelConfig::CollapseModelConfig(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), and NnetTrainer::TrainInternalBackstitch().
void kaldi::nnet3::ConstrainOrthonormalInternal | ( | BaseFloat | scale, |
CuMatrixBase< BaseFloat > * | M | ||
) |
Definition at line 982 of file nnet-utils.cc.
References CuMatrixBase< Real >::AddMat(), CuMatrixBase< Real >::AddMatMat(), CuMatrixBase< Real >::AddToDiag(), CuMatrixBase< Real >::CopyLowerToUpper(), CuMatrixBase< Real >::FrobeniusNorm(), kaldi::GetVerboseLevel(), KALDI_ASSERT, KALDI_VLOG, kaldi::kNoTrans, kaldi::kTrans, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), CuMatrixBase< Real >::SymAddMat2(), CuMatrixBase< Real >::Trace(), and kaldi::TraceMatMat().
Referenced by ConstrainOrthonormal().
bool kaldi::nnet3::ContainsSingleExample | ( | const NnetExample & | eg, |
int32 * | min_input_t, | ||
int32 * | max_input_t, | ||
int32 * | min_output_t, | ||
int32 * | max_output_t | ||
) |
Returns true if the "eg" contains just a single example, meaning that all the "n" values in the indexes are zero, and the example has NnetIo members named both "input" and "output".
Also computes the minimum and maximum "t" values in the "input" and "output" NnetIo members.
Definition at line 82 of file nnet3-copy-egs.cc.
References rnnlm::i, NnetIo::indexes, NnetExample::io, KALDI_ASSERT, KALDI_WARN, and NnetIo::name.
Referenced by SelectFromExample().
void ConvertAdditionToAssignment | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This converts addition operations (things with Add in their names) to copy operations (things with Copy in their names).
This is slightly more efficient, and it may later allow us to remove unnecessary zeroing.
Definition at line 430 of file nnet-optimize.cc.
References NnetComputation::Command::alpha, Analyzer::command_attributes, NnetComputation::Command::command_type, NnetComputation::commands, ComputationAnalysis::FirstNontrivialAccess(), Analyzer::Init(), kAddRows, kAddRowsMulti, kAddToRowsMulti, KALDI_ASSERT, KALDI_ERR, kCopyRows, kCopyRowsMulti, kCopyToRowsMulti, kMatrixAdd, and kMatrixCopy.
Referenced by Optimize().
|
static |
Definition at line 3106 of file nnet-optimize-utils.cc.
References KALDI_ASSERT, Index::n, and rnnlm::n.
Referenced by ComputationExpander::ExpandIndexes(), and IoSpecificationIsDecomposable().
void kaldi::nnet3::ConvertRepeatedToBlockAffine | ( | CompositeComponent * | c_component | ) |
Definition at line 447 of file nnet-utils.cc.
References CompositeComponent::GetComponent(), rnnlm::i, KALDI_ASSERT, CompositeComponent::NumComponents(), CompositeComponent::SetComponent(), and Component::Type().
Referenced by ConvertRepeatedToBlockAffine(), main(), UnitTestConvertRepeatedToBlockAffine(), and UnitTestConvertRepeatedToBlockAffineComposite().
void ConvertRepeatedToBlockAffine | ( | Nnet * | nnet | ) |
Convert all components of type RepeatedAffineComponent or NaturalGradientRepeatedAffineComponent to BlockAffineComponent in nnet.
Definition at line 468 of file nnet-utils.cc.
References ConvertRepeatedToBlockAffine(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, Nnet::NumComponents(), Nnet::SetComponent(), and Component::Type().
bool ConvertToIndexes | ( | const std::vector< std::pair< int32, int32 > > & | location_vector, |
int32 * | first_value, | ||
std::vector< int32 > * | second_values | ||
) |
If it is the case for some i >= 0 that all the .first elements of "location_vector" are either i or -1, then output i to first_value and the .second elements into "second_values", and return true.
Otherwise return false and the outputs are don't-cares.
Definition at line 190 of file nnet-compile-utils.cc.
Referenced by Compiler::CompileBackwardFromSubmatLocations(), Compiler::CompileForwardFromSubmatLocations(), SplitLocationsBackward(), UnitTestSplitLocations(), and UnitTestSplitLocationsBackward().
|
static |
Definition at line 31 of file nnet-general-component.cc.
References CuArrayBase< T >::CopyToVec().
Referenced by StatisticsExtractionComponentPrecomputedIndexes::Read(), StatisticsPoolingComponentPrecomputedIndexes::Read(), StatisticsExtractionComponentPrecomputedIndexes::Write(), and StatisticsPoolingComponentPrecomputedIndexes::Write().
|
static |
Definition at line 36 of file nnet-general-component.cc.
References CuArray< T >::CopyFromVec().
|
static |
Definition at line 113 of file nnet-compile-looped.cc.
References ComputationRequest::inputs, rnnlm::n, and ComputationRequest::outputs.
Referenced by CreateLoopedComputationRequest().
void CreateLoopedComputationRequest | ( | const Nnet & | nnet, |
int32 | chunk_size, | ||
int32 | frame_subsampling_factor, | ||
int32 | ivector_period, | ||
int32 | left_context_begin, | ||
int32 | right_context, | ||
int32 | num_sequences, | ||
ComputationRequest * | request1, | ||
ComputationRequest * | request2, | ||
ComputationRequest * | request3 | ||
) |
This function creates computation request suitable for giving to ComputeLooped().
It's intended for use with a 'simple' nnet (one satisfying IsSimpleNnet()), and this basically means that the inputs must be named "input" and possibly "ivector", and that there is an output named "output", and that those are the ones you care about (it won't generate any other outputs or use any other inputs).
If you want to use looped computation for different types of neural net, you should use the deeper interface, CompileLooped().
[in] | nnet | The neural net this computation request is to be used with. This is used to check whether the neural net accepts iVectors, and to work out the left-context and right-context required by the network. |
[in] | chunk_size | The number of frames of output that will be generated for each chunk (note: this is the shift in the t-index, which will not equal the number of output frames if frame_subsampling_factor != 1). Note: it is required that chunk_size be a multiple of ivector_period, frame_subsampling_factor, and nnet.Modulus(). You should use GetChunkSize() to compute the chunk size, giving it an advisory/ minimum chunksize, to make sure it satisfies these properties. |
[in] | frame_subsampling_factor | This will normally be 1, but may be more than 1 (e.g. 3) in chain systems; it determines the frame-skipping on the output, so we evaluate the output with 't' at multiples of this value. |
[in] | ivector_period | The period with which iVectors are to be supplied to the network (if you're using iVectors). Not necessarily the same as the period with which the ivectors are extracted or stored on disk (–online-ivector-period). You will normally set this to the chunk size. It must divide the chunk size (if you're using iVectors) Note: you should call ModifyNnetIvectorPeriod on 'nnet' before calling this function; otherwise the neural net will most likely not actually be able to consume the iVector with this frequency. |
[in] | left_context_begin | This should be the left-context of the network plus any additional left-context (provided via the option –extra-left-context-begin) that should be supplied to the network on top of the minimum that the network requires. We call this left_context_begin because this only relates to the start of the utterance (t=0). |
[in] | right_context | This should be the right-context of the network, plus any additional right-context ("extra-right-context") that should be supplied to the network on top of the minimum that the network requires (currently extra-right-context != 0 is is not supported at the command-line level). |
[in] | num_sequences | The number of separate 'n' values to put in the computation; normally this will be just 1, but it can be increased to allow simultaneous operation on multiple streams of input. |
[out] | request1 | The first of the 3 requests that this function generates, that the user should then supply to CompileLooped(). Note: this will tend to be the largest computation request in terms of input, because we have to provide enough left and right context that it can evaluate the first chunk. Note: as elsewhere, the job of duplicating first and last frames enough to provide the required left/right context to the network, is left to the caller (at runtime, not during compilation). |
[out] | request2 | The second of the 3 requests that this function generates. Caution: none of the inputs and outputs should overlap. |
[out] | request3 | The third of the 3 requests that this function generates. It will be the same as request2, except for a time offset. |
Definition at line 164 of file nnet-compile-looped.cc.
References CreateComputationRequestInternal(), Nnet::InputDim(), KALDI_ASSERT, Mod(), and Nnet::Modulus().
Referenced by CreateLoopedComputationRequestSimple(), and DecodableNnetSimpleLoopedInfo::Init().
void CreateLoopedComputationRequestSimple | ( | const Nnet & | nnet, |
int32 | chunk_size, | ||
int32 | frame_subsampling_factor, | ||
int32 | ivector_period, | ||
int32 | extra_left_context_begin, | ||
int32 | extra_right_context, | ||
int32 | num_sequences, | ||
ComputationRequest * | request1, | ||
ComputationRequest * | request2, | ||
ComputationRequest * | request3 | ||
) |
This function is deprecated.
It has the same interface as CreateLoopedComputationRequest(), except that the left and right context are specified in a different way (as just the 'extra' part). It is deprecated because this function has to work out the left and right context of the network, which turns out to be quite slow if it's done after you call ModifyNnetIvectorPeriod().
Definition at line 361 of file nnet-compile-looped.cc.
References ComputeSimpleNnetContext(), and CreateLoopedComputationRequest().
Referenced by UnitTestNnetCompileLooped().
bool DescriptorTokenize | ( | const std::string & | input, |
std::vector< std::string > * | tokens | ||
) |
This function tokenizes input when parsing Descriptor configuration values.
A token in this context is not the same as a generic Kaldi token, e.g. as defined in IsToken() in util/text_utils.h, which just means a non-empty whitespace-free string. Here a token is more like a programming-language token, and currently the following are allowed as tokens: "(" ")" ","
This function should return false and print an informative error with local context if it can't tokenize the input.
Definition at line 30 of file nnet-parse.cc.
References kaldi::ConvertStringToReal(), ErrorContext(), kaldi::IsValidName(), KALDI_ASSERT, and KALDI_WARN.
Referenced by NormalizeTextDescriptor(), Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessOutputNodeConfigLine(), Nnet::RemoveSomeNodes(), ModelCollapser::ReplaceNodeInDescriptor(), UnitTestDescriptorIo(), UnitTestDescriptorTokenize(), and UnitTestGeneralDescriptor().
This function divides the number 'a' into 'b' pieces, such that the sum of the pieces equals 'a' and no two pieces differ by more than 1.
[in] | a | A number, may be positive or negative |
[in] | b | The number of pieces, b >= 1. |
[out] | pieces | The pieces will be written to here. At exit, their sum will equal a, and none of them will differ from any other by more than 1. Otherwise they are arbitrarily chosen. |
Definition at line 72 of file nnet3-xvector-compute-batched.cc.
References rnnlm::i, and KALDI_ASSERT.
Referenced by BatchedXvectorComputer::SplitUtteranceIntoChunks().
Returns dot product between two networks of the same structure (calls the DotProduct functions of the Updatable components and sums up the return values).
Definition at line 250 of file nnet-utils.cc.
References UpdatableComponent::DotProduct(), Nnet::GetComponent(), KALDI_ASSERT, kUpdatableComponent, Nnet::NumComponents(), and Component::Properties().
Referenced by AffineComponent::BackpropNeedsOutput(), BlockAffineComponent::BackpropNeedsOutput(), Convolutional1dComponent::BackpropNeedsOutput(), LstmNonlinearityComponent::ConsolidateMemory(), ScaleAndOffsetComponent::Copy(), ConstantComponent::IsComputable(), LinearComponent::LinearComponent(), AffineComponent::Properties(), BlockAffineComponent::Properties(), RepeatedAffineComponent::Properties(), PerElementScaleComponent::Properties(), PerElementOffsetComponent::Properties(), ConstantFunctionComponent::Properties(), NnetDiscriminativeTrainer::Train(), CompositeComponent::Type(), UnitTestNnetModelDerivatives(), and UpdatableComponent::~UpdatableComponent().
void EnsureContiguousProperty | ( | const std::vector< int32 > & | indexes, |
std::vector< std::vector< int32 > > * | indexes_out | ||
) |
This function takes a vector of indexes and splits it up into as separate vectors of the same size, as needed to ensure that the 'contiguous property' holds.
This is done via padding with -1's. An example will clarify this. Suppose the input is: [ -1 1 1 1 2 2 1 1 ] which lacks the contiguous property because 1's appear in 2 different places, it would split it up as [ -1 1 1 1 2 2 -1 -1 ] [ -1 -1 -1 -1 -1 -1 1 1 ] If 'indexes' is empty or only contains -1's, 'indexes_out' will be empty.
Definition at line 214 of file nnet-compile-utils.cc.
References rnnlm::i.
Referenced by SplitLocationsBackward(), and UnitTestEnsureContiguousProperty().
std::string ErrorContext | ( | std::istream & | is | ) |
Return a string used in error messages.
Here, "is" will be from an istringstream derived from a single line or part of a line. If "is" is at EOF or in error state, this should just say "end of line", else if the contents of "is" before EOF is <20 characters it should return it all, else it should return the first 20 characters followed by "...".
Definition at line 78 of file nnet-parse.cc.
Referenced by DescriptorTokenize().
std::string ErrorContext | ( | const std::string & | str | ) |
Definition at line 88 of file nnet-parse.cc.
void EvaluateComputationRequest | ( | const Nnet & | nnet, |
const ComputationRequest & | request, | ||
std::vector< std::vector< bool > > * | is_computable | ||
) |
Given an nnet and a computation request, this function works out which requested outputs in the computation request are computable; it outputs this information as a vector "is_computable" indexed by the same indexes as request.outputs.
It does this by executing some of the early stages of compilation.
Definition at line 71 of file nnet-utils.cc.
References ComputationGraphBuilder::Compute(), ComputationGraphBuilder::GetComputableInfo(), Nnet::GetNodeNames(), kaldi::GetVerboseLevel(), KALDI_VLOG, and ComputationGraph::Print().
Referenced by ComputeSimpleNnetContextForShift().
bool ExampleApproxEqual | ( | const NnetExample & | eg1, |
const NnetExample & | eg2, | ||
BaseFloat | delta | ||
) |
Returns true if the examples are approximately equal (only intended to be used in testing).
Definition at line 1885 of file nnet-test-utils.cc.
References kaldi::ApproxEqual(), NnetIo::features, GeneralMatrix::GetMatrix(), rnnlm::i, NnetIo::indexes, NnetExample::io, and NnetIo::name.
Referenced by NnetGenerationOptions::NnetGenerationOptions(), and UnitTestNnetExample().
void ExpandComputation | ( | const Nnet & | nnet, |
const MiscComputationInfo & | misc_info, | ||
const NnetComputation & | computation, | ||
bool | need_debug_info, | ||
int32 | num_n_values, | ||
NnetComputation * | expanded_computation | ||
) |
This function is used in 'shortcut' compilation to expand a computation that has been compiled for exactly 2 'n' values, to one that is suitable for some num_n_values > 2.
[in] | nnet | The neural network for which this computation is being built. |
[in] | misc_info | The same MiscComputationInfo object that was present in the ComputationRequests that were originally used to generate the computation (required to generated the PrecomputedIndexes) |
[in] | computation | The computation that was compiled for exactly 2 'n' values (n=0 and n=1) |
[in] | need_debug_info | True if we want to retain the 'debug_info' in the output 'expanded_computation'. In any case, the 'debug_info' is required in the input computation. |
[in] | num_n_values | The number of 'n' values we want in the output computation |
[out] | expanded_computation | The expanded computation. |
Definition at line 3804 of file nnet-optimize-utils.cc.
References ComputationExpander::Expand().
Referenced by CachingOptimizingCompiler::CompileViaShortcut().
|
static |
Definition at line 45 of file nnet-descriptor.cc.
References KALDI_ERR, and ParsingContext().
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), GeneralDescriptor::Parse(), GeneralDescriptor::ParseConst(), GeneralDescriptor::ParseFailover(), GeneralDescriptor::ParseIfDefined(), GeneralDescriptor::ParseOffset(), GeneralDescriptor::ParseReplaceIndex(), GeneralDescriptor::ParseRound(), GeneralDescriptor::ParseScale(), AmNnetSimple::Read(), PnormComponent::Read(), Index::Read(), DistributeComponent::Read(), NnetIo::Read(), NnetDiscriminativeSupervision::Read(), IoSpecification::Read(), NormalizeComponent::Read(), NnetChainSupervision::Read(), NnetDiscriminativeExample::Read(), NnetExample::Read(), DropoutComponent::Read(), NnetChainExample::Read(), NnetOptimizeOptions::Read(), DistributeComponentPrecomputedIndexes::Read(), RestrictedAttentionComponent::Read(), ComputationRequest::Read(), ConvolutionComponent::Read(), ElementwiseProductComponent::Read(), RestrictedAttentionComponent::PrecomputedIndexes::Read(), BatchNormComponent::Read(), Nnet::Read(), StatisticsExtractionComponent::Read(), ConvolutionModel::Read(), TimeHeightConvolutionComponent::Read(), TimeHeightConvolutionComponent::PrecomputedIndexes::Read(), StatisticsExtractionComponentPrecomputedIndexes::Read(), NnetComputation::MatrixInfo::Read(), NnetComputation::MatrixDebugInfo::Read(), NnetComputation::SubMatrixInfo::Read(), ConvolutionComputation::Read(), LstmNonlinearityComponent::Read(), NnetComputation::Command::Read(), StatisticsPoolingComponent::Read(), ConvolutionComputationIo::Read(), AffineComponent::Read(), StatisticsPoolingComponentPrecomputedIndexes::Read(), NnetComputation::Read(), TdnnComponent::Read(), BackpropTruncationComponent::Read(), MaxpoolingComponent::Read(), BlockAffineComponent::Read(), TdnnComponent::PrecomputedIndexes::Read(), BackpropTruncationComponentPrecomputedIndexes::Read(), RepeatedAffineComponent::Read(), NonlinearComponent::Read(), ComputationCache::Read(), ConstantComponent::Read(), DropoutMaskComponent::Read(), NaturalGradientAffineComponent::Read(), GeneralDropoutComponent::Read(), LinearComponent::Read(), GeneralDropoutComponentPrecomputedIndexes::Read(), FixedAffineComponent::Read(), SpecAugmentTimeMaskComponent::Read(), SpecAugmentTimeMaskComponentPrecomputedIndexes::Read(), FixedScaleComponent::Read(), FixedBiasComponent::Read(), NoOpComponent::Read(), SumBlockComponent::Read(), ClipGradientComponent::Read(), PermuteComponent::Read(), PerElementScaleComponent::Read(), PerElementOffsetComponent::Read(), ConstantFunctionComponent::Read(), NaturalGradientPerElementScaleComponent::Read(), ScaleAndOffsetComponent::Read(), CompositeComponent::Read(), ReadCindexVector(), and ReadIndexVector().
void ExtendMatrices | ( | NnetComputation * | computation | ) |
This is not really an optimization in itself but it can make things easier for class VariableMergingOptimizer (usually called by its wrapper VariableMergingOptimization()).
It looks for a case where most of a matrix (but not its final rows) are copied to some submatrix of another matrix, where the row-range of that submatrix extends to the last row of the other matrix; and it extends the other matrix with additional rows so that the entire source matrix can be copied to the destination.
Definition at line 1270 of file nnet-optimize-utils.cc.
References MatrixExtender::ExtendMatrices().
Referenced by Optimize().
|
static |
Definition at line 251 of file nnet-compile-looped.cc.
References AddTimeOffsetToComputationRequest(), ComputationRequest::inputs, and KALDI_ASSERT.
Referenced by CompileLoopedInternal().
void kaldi::nnet3::FilterExample | ( | const NnetExample & | eg, |
int32 | min_input_t, | ||
int32 | max_input_t, | ||
int32 | min_output_t, | ||
int32 | max_output_t, | ||
NnetExample * | eg_out | ||
) |
This function filters the indexes (and associated feature rows) in a NnetExample, removing any index/row in an NnetIo named "input" with t < min_input_t or t > max_input_t and any index/row in an NnetIo named "output" with t < min_output_t or t > max_output_t.
Will crash if filtering removes all Indexes of "input" or "output".
Definition at line 145 of file nnet3-copy-egs.cc.
References NnetIo::features, kaldi::FilterGeneralMatrixRows(), rnnlm::i, NnetIo::indexes, NnetExample::io, KALDI_ASSERT, KALDI_ERR, NnetIo::name, and GeneralMatrix::NumRows().
Referenced by SelectFromExample().
|
static |
Definition at line 2942 of file nnet-optimize-utils.cc.
References rnnlm::i, rnnlm::j, KALDI_ASSERT, Index::n, rnnlm::n, kaldi::RandInt(), and kaldi::SortAndUniq().
Referenced by ComputationExpander::ExpandIndexes(), ComputationExpander::InitStrideInfo(), and IoSpecificationIsDecomposable().
|
static |
Definition at line 3033 of file nnet-optimize-utils.cc.
References rnnlm::i, rnnlm::j, KALDI_ASSERT, rnnlm::n, kaldi::RandInt(), and kaldi::SortAndUniq().
|
static |
Definition at line 2477 of file nnet-optimize-utils.cc.
References KALDI_ASSERT.
Referenced by SnipRangesRowOp().
|
static |
Definition at line 2339 of file nnet-optimize-utils.cc.
References KALDI_ASSERT.
Referenced by SnipMultiRowOp(), and SnipSingleRowOp().
|
static |
This function finds a list of components that are never used, and outputs the integer comopnent indexes (you can use these to index nnet.GetComponentNames() to get their names).
Definition at line 591 of file nnet-utils.cc.
References NetworkNode::component_index, Nnet::GetNode(), rnnlm::i, Nnet::IsComponentNode(), KALDI_ASSERT, Nnet::NumComponents(), Nnet::NumNodes(), and NetworkNode::u.
Referenced by Nnet::Check(), and Nnet::RemoveOrphanComponents().
This function finds a list of nodes that are never used to compute any output, and outputs the integer node indexes (you can use these to index nnet.GetNodeNames() to get their names).
Definition at line 607 of file nnet-utils.cc.
References ComputeGraphTranspose(), rnnlm::i, Nnet::IsOutputNode(), rnnlm::j, NnetToDirectedGraph(), and Nnet::NumNodes().
Referenced by Nnet::Check(), and Nnet::RemoveOrphanNodes().
void FindSccs | ( | const std::vector< std::vector< int32 > > & | graph, |
std::vector< std::vector< int32 > > * | sccs | ||
) |
Given a directed graph (where each std::vector<int32> is a list of destination-nodes of arcs coming from the current node), partition it into strongly connected components (i.e.
within each SCC, all nodes are reachable from all other nodes). Each element of 'sccs' is a list of node indexes that are in that scc.
Definition at line 156 of file nnet-graph.cc.
References FindSccsTarjan(), and KALDI_ASSERT.
Referenced by ComputeNnetComputationEpochs(), GraphHasCycles(), and UnitTestFindSccs().
void kaldi::nnet3::FindSccsTarjan | ( | const std::vector< std::vector< int32 > > & | graph, |
std::vector< std::vector< int32 > > * | sccs | ||
) |
Definition at line 138 of file nnet-graph.cc.
References TarjanNode::index, KALDI_ASSERT, rnnlm::n, and TarjanSccRecursive().
Referenced by FindSccs().
void FixGotoLabel | ( | NnetComputation * | computation | ) |
This function ensures that the arg1 of a final command of type kGotoLabel is the same as the command with type kNoOperationLabel.
This is necessary if you do any other type of optimization after 'OptimizeLoopedComputation()'.
Definition at line 4552 of file nnet-optimize-utils.cc.
References NnetComputation::commands, rnnlm::d, KALDI_ERR, kGotoLabel, kNoOperationLabel, and kProvideOutput.
Referenced by InsertCommands(), Optimize(), ComputationLoopedOptimizer::Optimize(), and RemoveUnnecessaryAllocation().
Controls if natural gradient will be updated.
Definition at line 432 of file nnet-utils.cc.
References UpdatableComponent::FreezeNaturalGradient(), Nnet::GetComponent(), KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), and Component::Properties().
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), LinearComponent::LinearComponent(), NaturalGradientAffineComponent::NaturalGradientAffineComponent(), NnetChainTrainer::Train(), NnetTrainer::Train(), NaturalGradientPerElementScaleComponent::Type(), and CompositeComponent::Type().
void GenerateConfigSequence | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Generates a sequence of at least one config files, output as strings, where the first in the sequence is the initial nnet, and the remaining ones may do things like add layers.
Definition at line 1252 of file nnet-test-utils.cc.
References NnetGenerationOptions::allow_context, NnetGenerationOptions::allow_nonlinearity, NnetGenerationOptions::allow_recursion, NnetGenerationOptions::allow_statistics_pooling, NnetGenerationOptions::allow_use_of_x_dim, GenerateConfigSequenceCnn(), GenerateConfigSequenceCnnNew(), GenerateConfigSequenceCompositeBlock(), GenerateConfigSequenceDistribute(), GenerateConfigSequenceLstm(), GenerateConfigSequenceLstmWithTruncation(), GenerateConfigSequenceRestrictedAttention(), GenerateConfigSequenceRnn(), GenerateConfigSequenceRnnClockwork(), GenerateConfigSequenceSimple(), GenerateConfigSequenceSimpleContext(), GenerateConfigSequenceSimplest(), GenerateConfigSequenceStatistics(), KALDI_ASSERT, KALDI_ERR, and kaldi::RandInt().
Referenced by NnetGenerationOptions::NnetGenerationOptions(), UnitTestNnetAnalyze(), UnitTestNnetCompile(), UnitTestNnetCompileLooped(), UnitTestNnetCompileMulti(), UnitTestNnetCompute(), UnitTestNnetContext(), UnitTestNnetInputDerivatives(), UnitTestNnetIo(), UnitTestNnetModelDerivatives(), and UnitTestNnetOptimizeWithOptions().
void kaldi::nnet3::GenerateConfigSequenceCnn | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 913 of file nnet-test-utils.cc.
References kaldi::Rand().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceCnnNew | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 994 of file nnet-test-utils.cc.
References kaldi::RandInt().
Referenced by GenerateConfigSequence().
void GenerateConfigSequenceCompositeBlock | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Generate a config string with a composite component composed only of block affine, repeated affine, and natural gradient repeated affine components.
Definition at line 1213 of file nnet-test-utils.cc.
References rnnlm::i, KALDI_WARN, NnetGenerationOptions::output_dim, and kaldi::RandInt().
Referenced by GenerateConfigSequence(), NnetGenerationOptions::NnetGenerationOptions(), and UnitTestConvertRepeatedToBlockAffineComposite().
void kaldi::nnet3::GenerateConfigSequenceDistribute | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 1187 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, and kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceLstm | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 414 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, and kaldi::Rand().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceLstmType2 | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 767 of file nnet-test-utils.cc.
References rnnlm::i, KALDI_ERR, NnetGenerationOptions::output_dim, kaldi::Rand(), and kaldi::RandInt().
void kaldi::nnet3::GenerateConfigSequenceLstmWithTruncation | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 580 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, kaldi::Rand(), and kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceRestrictedAttention | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 1130 of file nnet-test-utils.cc.
References kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceRnn | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 263 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, kaldi::Rand(), and kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceRnnClockwork | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 322 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, and kaldi::Rand().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceSimple | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 111 of file nnet-test-utils.cc.
References NnetGenerationOptions::allow_final_nonlinearity, NnetGenerationOptions::allow_ivector, rnnlm::i, NnetGenerationOptions::output_dim, kaldi::Rand(), and kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceSimpleContext | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 54 of file nnet-test-utils.cc.
References rnnlm::i, NnetGenerationOptions::output_dim, kaldi::Rand(), and kaldi::RandInt().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceSimplest | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 33 of file nnet-test-utils.cc.
References NnetGenerationOptions::output_dim, and kaldi::Rand().
Referenced by GenerateConfigSequence().
void kaldi::nnet3::GenerateConfigSequenceStatistics | ( | const NnetGenerationOptions & | opts, |
std::vector< std::string > * | configs | ||
) |
Definition at line 219 of file nnet-test-utils.cc.
References kaldi::RandInt().
Referenced by GenerateConfigSequence().
|
static |
Definition at line 1400 of file nnet-test-utils.cc.
References rnnlm::i, KALDI_ERR, rnnlm::n, kaldi::Rand(), kaldi::RandInt(), and kaldi::RandUniform().
Referenced by GenerateRandomSimpleComponent().
Component * GenerateRandomSimpleComponent | ( | ) |
Generates random simple component for testing.
Definition at line 1783 of file nnet-test-utils.cc.
References GenerateRandomComponentConfig(), ConfigLine::HasUnusedValues(), Component::InitFromConfig(), KALDI_ERR, Component::NewComponentOfType(), ConfigLine::ParseLine(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
Referenced by NnetGenerationOptions::NnetGenerationOptions(), and UnitTestNnetComponent().
void GenerateSimpleNnetTrainingExample | ( | int32 | num_supervised_frames, |
int32 | left_context, | ||
int32 | right_context, | ||
int32 | input_dim, | ||
int32 | output_dim, | ||
int32 | ivector_dim, | ||
NnetExample * | example | ||
) |
Low-level function that generates an nnet training example.
By "simple" we mean there is one output named "output", an input named "input", and possibly also an input named "ivector" (this will be assumed absent if ivector_dim <= 0). This function generates exactly "left_context" or "right_context" frames of context on the left and right respectively.
Definition at line 1832 of file nnet-test-utils.cc.
References GeneralMatrix::Compress(), NnetIo::features, rnnlm::i, NnetExample::io, KALDI_ASSERT, kaldi::RandInt(), kaldi::RandUniform(), and MatrixBase< Real >::SetRandn().
Referenced by NnetGenerationOptions::NnetGenerationOptions(), UnitTestNnetExample(), and UnitTestNnetMergeExamples().
void kaldi::nnet3::GenRandDescriptor | ( | int32 | num_nodes, |
Descriptor * | desc | ||
) |
Definition at line 76 of file nnet-descriptor-test.cc.
References GenRandSumDescriptor(), and kaldi::Rand().
Referenced by UnitTestDescriptorIo(), and UnitTestGeneralDescriptor().
ForwardingDescriptor* kaldi::nnet3::GenRandForwardingDescriptor | ( | int32 | num_nodes | ) |
Definition at line 25 of file nnet-descriptor-test.cc.
References rnnlm::i, ReplaceIndexForwardingDescriptor::kT, ReplaceIndexForwardingDescriptor::kX, rnnlm::n, kaldi::Rand(), Index::t, and Index::x.
Referenced by GenRandSumDescriptor().
SumDescriptor* kaldi::nnet3::GenRandSumDescriptor | ( | int32 | num_nodes | ) |
Definition at line 57 of file nnet-descriptor-test.cc.
References GenRandForwardingDescriptor(), BinarySumDescriptor::kFailoverOperation, BinarySumDescriptor::kSumOperation, and kaldi::Rand().
Referenced by GenRandDescriptor().
void GetChainComputationRequest | ( | const Nnet & | nnet, |
const NnetChainExample & | eg, | ||
bool | need_model_derivative, | ||
bool | store_component_stats, | ||
bool | use_xent_regularization, | ||
bool | use_xent_derivative, | ||
ComputationRequest * | computation_request | ||
) |
This function takes a NnetChainExample and produces a ComputationRequest.
Assumes you don't want the derivatives w.r.t. the inputs; if you do, you can create the ComputationRequest manually. Assumes that if need_model_derivative is true, you will be supplying derivatives w.r.t. all outputs.
If use_xent_regularization == true, then it assumes that for each output name (e.g. "output" in the eg, there is another output with the same dimension and with the suffix "-xent" on its name, e.g. named "output-xent". The derivative w.r.t. the xent objective will only be supplied to the nnet computation if 'use_xent_derivative' is true (we propagate back the xent derivative to the model only in training, not in model-combination in nnet3-chain-combine).
Definition at line 290 of file nnet-chain-example.cc.
References Nnet::GetNodeIndex(), IoSpecification::has_deriv, rnnlm::i, NnetIo::indexes, NnetChainSupervision::indexes, IoSpecification::indexes, NnetChainExample::inputs, ComputationRequest::inputs, Nnet::IsInputNode(), Nnet::IsOutputNode(), KALDI_ERR, NnetIo::name, NnetChainSupervision::name, IoSpecification::name, ComputationRequest::need_model_derivative, ComputationRequest::outputs, NnetChainExample::outputs, and ComputationRequest::store_component_stats.
Referenced by NnetChainComputeProb::Compute(), NnetChainExampleStructureCompare::operator()(), and NnetChainTrainer::Train().
int32 kaldi::nnet3::GetChainNnetExampleSize | ( | const NnetChainExample & | a | ) |
This function returns the 'size' of a chain example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example.
Definition at line 81 of file nnet-compile-looped.cc.
References KALDI_ASSERT, and Nnet::Modulus().
Referenced by DecodableNnetSimpleLoopedInfo::Init(), and UnitTestNnetCompileLooped().
void GetCommandsOfType | ( | const NnetComputation & | computation, |
CommandType | t, | ||
std::vector< int32 > * | command_indexes | ||
) |
This utility function works out from a computation, the command-indexes of the commands of the given type.
Definition at line 1429 of file nnet-analyze.cc.
References NnetComputation::commands.
Referenced by ComputationLoopedOptimizer::FindTimeShift(), and ComputationLoopedOptimizer::Optimize().
void GetComputationRequest | ( | const Nnet & | nnet, |
const NnetExample & | eg, | ||
bool | need_model_derivative, | ||
bool | store_component_stats, | ||
ComputationRequest * | computation_request | ||
) |
This function takes a NnetExample (which should already have been frame-selected, if desired, and merged into a minibatch) and produces a ComputationRequest.
It assumes you don't want the derivatives w.r.t. the inputs; if you do, you can create/modify the ComputationRequest manually. Assumes that if need_model_derivative is true, you will be supplying derivatives w.r.t. all outputs.
Definition at line 202 of file nnet-example-utils.cc.
References Nnet::GetNodeIndex(), IoSpecification::has_deriv, rnnlm::i, NnetIo::indexes, IoSpecification::indexes, ComputationRequest::inputs, NnetExample::io, Nnet::IsInputNode(), Nnet::IsOutputNode(), KALDI_ERR, NnetIo::name, IoSpecification::name, ComputationRequest::need_model_derivative, ComputationRequest::outputs, and ComputationRequest::store_component_stats.
Referenced by NnetLdaStatsAccumulator::AccStats(), NnetComputerFromEg::Compute(), NnetComputeProb::Compute(), and NnetTrainer::Train().
int32 kaldi::nnet3::GetCount | ( | double | expected_count | ) |
Definition at line 66 of file nnet3-copy-egs.cc.
References KALDI_ASSERT, and kaldi::WithProb().
Referenced by main().
void GetDiscriminativeComputationRequest | ( | const Nnet & | nnet, |
const NnetDiscriminativeExample & | eg, | ||
bool | need_model_derivative, | ||
bool | store_component_stats, | ||
bool | use_xent_regularization, | ||
bool | use_xent_derivative, | ||
ComputationRequest * | computation_request | ||
) |
This function takes a NnetDiscriminativeExample and produces a ComputationRequest.
Assumes you don't want the derivatives w.r.t. the inputs; if you do, you can create the ComputationRequest manually. Assumes that if need_model_derivative is true, you will be supplying derivatives w.r.t. all outputs.
Definition at line 284 of file nnet-discriminative-example.cc.
References Nnet::GetNodeIndex(), IoSpecification::has_deriv, rnnlm::i, NnetIo::indexes, NnetDiscriminativeSupervision::indexes, IoSpecification::indexes, NnetDiscriminativeExample::inputs, ComputationRequest::inputs, Nnet::IsInputNode(), Nnet::IsOutputNode(), KALDI_ERR, NnetIo::name, NnetDiscriminativeSupervision::name, IoSpecification::name, ComputationRequest::need_model_derivative, NnetDiscriminativeExample::outputs, ComputationRequest::outputs, and ComputationRequest::store_component_stats.
Referenced by NnetDiscriminativeComputeObjf::Compute(), NnetDiscriminativeExampleStructureCompare::operator()(), and NnetDiscriminativeTrainer::Train().
int32 kaldi::nnet3::GetDiscriminativeNnetExampleSize | ( | const NnetDiscriminativeExample & | a | ) |
This function returns the 'size' of a discriminative example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example.
|
static |
Definition at line 462 of file nnet-computation.cc.
References NnetComputation::SubMatrixInfo::col_offset, rnnlm::i, NnetComputation::indexes_multi, rnnlm::j, KALDI_WARN, NnetComputation::matrices, NnetComputation::SubMatrixInfo::matrix_index, NnetComputation::MatrixInfo::num_cols, NnetComputation::SubMatrixInfo::num_cols, NnetComputation::MatrixInfo::num_rows, NnetComputation::SubMatrixInfo::num_rows, NnetComputation::SubMatrixInfo::row_offset, and NnetComputation::submatrices.
Referenced by NnetComputation::GetCommandStrings(), and NnetComputation::Print().
|
static |
Definition at line 448 of file nnet-computation.cc.
References rnnlm::i, NnetComputation::indexes, and PrintIntegerVector().
Referenced by NnetComputation::GetCommandStrings(), and NnetComputation::Print().
|
static |
Definition at line 34 of file nnet-example-utils.cc.
References kaldi::CopySetToVector().
Referenced by MergeExamples().
|
static |
Definition at line 50 of file nnet-example-utils.cc.
References NnetIo::features, rnnlm::i, NnetIo::indexes, KALDI_ASSERT, KALDI_ERR, NnetIo::name, GeneralMatrix::NumCols(), and GeneralMatrix::NumRows().
Referenced by MergeExamples().
int64 GetMaxMemoryUse | ( | const NnetComputation & | computation | ) |
Definition at line 1439 of file nnet-analyze.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::command_type, NnetComputation::commands, kAcceptInput, KALDI_ASSERT, kAllocMatrix, kaldi::kCompressedMatrixInt8, kaldi::kCompressedMatrixUint8, kCompressMatrix, kDeallocMatrix, kDecompressMatrix, NnetComputation::SubMatrixInfo::num_cols, NnetComputation::SubMatrixInfo::num_rows, and NnetComputation::submatrices.
Referenced by Optimize(), and OptimizeMemoryCompression().
int32 kaldi::nnet3::GetNnetChainExampleSize | ( | const NnetChainExample & | a | ) |
Definition at line 437 of file nnet-chain-example.cc.
References rnnlm::i, NnetChainExample::inputs, and NnetChainExample::outputs.
Referenced by ChainExampleMerger::AcceptExample(), ChainExampleMerger::Finish(), and ChainExampleMerger::WriteMinibatch().
int32 kaldi::nnet3::GetNnetDiscriminativeExampleSize | ( | const NnetDiscriminativeExample & | a | ) |
Definition at line 430 of file nnet-discriminative-example.cc.
References rnnlm::i, NnetDiscriminativeExample::inputs, and NnetDiscriminativeExample::outputs.
Referenced by DiscriminativeExampleMerger::AcceptExample(), DiscriminativeExampleMerger::Finish(), and DiscriminativeExampleMerger::WriteMinibatch().
int32 GetNnetExampleSize | ( | const NnetExample & | a | ) |
This function returns the 'size' of a nnet-example as defined for purposes of merging egs, which is defined as the largest number of Indexes in any of the inputs or outputs of the example.
Definition at line 1178 of file nnet-example-utils.cc.
References rnnlm::i, and NnetExample::io.
Referenced by ExampleMerger::AcceptExample(), ExampleMerger::Finish(), and ExampleMerger::WriteMinibatch().
This utility function can be used to obtain the number of distinct 'n' values in a training example.
This is the number of examples (e.g. sequences) that have been combined into a single example. (Actually it returns the (largest - smallest + 1) of 'n' values, and assumes they are consecutive).
[in] | vec | The vector of NnetIo objects from the training example (NnetExample or NnetChainExample) for which we need the number of 'n' values |
[in] | exhaustive | If true, it will check exhaustively what largest and smallest 'n' values are. If 'false' it does it in a fast way which will return the same answer as if exhaustive == true for all the types of eg we currently create (basically: correct if the last row of the input or supervision matrices has the last-numbered 'n' value), and will occasionally (randomly) do a test to check that this is the same as if we called it with 'exhaustive=true'. |
Definition at line 2198 of file nnet-utils.cc.
References rnnlm::i, NnetIo::indexes, KALDI_ASSERT, KALDI_ERR, rnnlm::n, and kaldi::RandInt().
Referenced by CollapseModelConfig::CollapseModelConfig(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), and NnetTrainer::TrainInternalBackstitch().
void GetNxList | ( | const std::vector< Index > & | indexes, |
std::vector< std::pair< int32, int32 > > * | pairs | ||
) |
This function outputs a unique, lexicographically sorted list of the pairs of (n, x) values that are encountered in the provided list of Indexes.
Definition at line 416 of file nnet-compile-utils.cc.
Referenced by kaldi::nnet3::time_height_convolution::GetComputationIo(), RestrictedAttentionComponent::GetIndexes(), and kaldi::nnet3::time_height_convolution::GetIndexesForComputation().
ComponentPrecomputedIndexes* kaldi::nnet3::GetPrecomputedIndexes | ( | const Component & | c, |
int32 | num_rows | ||
) |
Definition at line 180 of file nnet-component-test.cc.
References rnnlm::i, kReordersIndexes, Component::PrecomputeIndexes(), Component::Properties(), and Component::ReorderIndexes().
Referenced by TestSimpleComponentDataDerivative(), TestSimpleComponentModelDerivative(), and TestSimpleComponentPropagateProperties().
void kaldi::nnet3::GetSubmatCounts | ( | const std::vector< std::vector< std::pair< int32, int32 > > > & | submat_lists, |
std::unordered_map< int32, int32 > * | submat_counts, | ||
std::vector< int32 > * | submats_with_large_counts | ||
) |
Gets counts of submatrices (the 1st members of pairs) in submat_lists.
Also outputs, to 'submats_with_large_counts', a list of submatrix indexes that have counts over half of submat_lists.size(). (These will be separated out into their own AddRows() commands).
Definition at line 35 of file nnet-compile-utils.cc.
References KALDI_ASSERT.
Referenced by SplitLocations().
|
static |
This static function returns a SubMatrixInfo corresponding to replacing the matrix-index in a's "matrix_index" with, essentially, sub-matrix b.
Of course the matrix_index will be b's "matrix_index", but we may have to modify the row and column offsets. The idea is that sub-matrix submat_b should have the same dimensions as the matrix underlying submat_a.
Definition at line 789 of file nnet-optimize-utils.cc.
References NnetComputation::SubMatrixInfo::col_offset, KALDI_ASSERT, NnetComputation::matrices, NnetComputation::SubMatrixInfo::matrix_index, NnetComputation::MatrixInfo::num_cols, NnetComputation::SubMatrixInfo::num_cols, NnetComputation::MatrixInfo::num_rows, NnetComputation::SubMatrixInfo::num_rows, NnetComputation::SubMatrixInfo::row_offset, and NnetComputation::submatrices.
Referenced by VariableMergingOptimizer::DoMerge().
This function outputs a sorted, unique list of the 't' values that are encountered in the provided list of Indexes If 't' values equal to kNoTime are encountered, they are ignored and are not output.
Definition at line 434 of file nnet-compile-utils.cc.
References kNoTime.
Referenced by kaldi::nnet3::time_height_convolution::GetComputationIo().
This function returns 'true' if the graph represented in 'graph' contains cycles (including cycles where a single node has an arc to itself).
Definition at line 300 of file nnet-graph.cc.
References FindSccs(), and rnnlm::i.
Referenced by NnetIsRecurrent().
Returns true if nnet has at least one component of type BatchNormComponent.
Definition at line 527 of file nnet-utils.cc.
References Nnet::GetComponent(), and Nnet::NumComponents().
Referenced by main().
bool HasContiguousProperty | ( | const std::vector< int32 > & | indexes, |
std::vector< std::pair< int32, int32 > > * | reverse_indexes | ||
) |
This function returns true if for each integer i != -1, all the indexes j at which indexes[j] == i are consecutive with no gaps (more formally: if j1 < j2 < j3 and indexes[j1] != -1 and indexes[j1] == indexes[j3], then indexes[j1] == indexes[j2]).
For example, the vector [ 1 2 1 ] lacks the contiguous property because 1 appears in two places with a different number in the middle. If the vector has the contiguous property, this function also outputs to "reverse_indexes" the begin and end of these ranges, so that indexes[j] == i for all j such that (*reverse_indexes)[i].first <= j && j < (*reverse_indexes)[i].second.
Definition at line 369 of file nnet-compile-utils.cc.
References rnnlm::i, rnnlm::j, KALDI_ASSERT, and KALDI_WARN.
Referenced by Compiler::CompileBackwardFromIndexes(), UnitTestEnsureContiguousProperty(), and UnitTestHasContiguousProperty().
Definition at line 235 of file nnet-chain-diagnostics.cc.
References Nnet::GetNodeIndex(), Nnet::GetNodeNames(), and Nnet::IsOutputNode().
Referenced by RecomputeStats().
void IdentifyIndexesArgs | ( | std::vector< NnetComputation::Command > * | commands, |
std::vector< int32 * > * | indexes_args | ||
) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's 'indexes' array, and outputs a list of pointers to those arguments to 'indexes_args'.
Useful in renumbering code.
Definition at line 133 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg3, NnetComputation::Command::command_type, kAddRows, and kCopyRows.
Referenced by ComputationRenumberer::RenumberIndexes().
void IdentifyIndexesMultiArgs | ( | std::vector< NnetComputation::Command > * | commands, |
std::vector< int32 * > * | indexes_multi_args | ||
) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's indexes_multi array, and outputs a list of pointers to those arguments to 'indexes_multi_args'.
Useful in renumbering code.
Definition at line 105 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg2, NnetComputation::Command::command_type, kAddRowsMulti, kAddToRowsMulti, kCopyRowsMulti, and kCopyToRowsMulti.
Referenced by ComputationRenumberer::RemoveIndexesMultiDuplicates(), and ComputationRenumberer::RemoveUnusedIndexesMulti().
void IdentifyIndexesRangesArgs | ( | std::vector< NnetComputation::Command > * | commands, |
std::vector< int32 * > * | indexes_ranges_args | ||
) |
Identifies in the vector of commands, arguments that correspond to indexes into the computation's 'indexes_ranges' array, and outputs a list of pointers to those arguments to 'indexes_ranges_args'.
Useful in renumbering code.
Definition at line 121 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg3, NnetComputation::Command::command_type, and kAddRowRanges.
Referenced by ComputationRenumberer::RenumberIndexesRanges().
void kaldi::nnet3::IdentifyMatrixArgsInComputation | ( | NnetComputation * | computation, |
std::vector< int32 *> * | matrix_args | ||
) |
void IdentifySubmatrixArgs | ( | NnetComputation::Command * | command, |
std::vector< int32 * > * | submatrix_args | ||
) |
This function outputs to "submatrix_args" the addresses of a subset of arguments arg1 through arg6 in "command", that correspond to the indexes of submatrices.
This is useful in renumbering code. Note: some of the pointers may point to a zero value, for optional submatrix args.
Definition at line 28 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::arg4, NnetComputation::Command::arg5, NnetComputation::Command::arg6, NnetComputation::Command::command_type, kAcceptInput, kAddRowRanges, kAddRows, kAddRowsMulti, kAddToRowsMulti, KALDI_ERR, kAllocMatrix, kBackprop, kBackpropNoModelUpdate, kCopyRows, kCopyRowsMulti, kCopyToRowsMulti, kDeallocMatrix, kGotoLabel, kMatrixAdd, kMatrixCopy, kNoOperation, kNoOperationLabel, kNoOperationMarker, kNoOperationPermanent, kPropagate, kProvideOutput, kSetConst, and kSwapMatrix.
Referenced by IdentifySubmatrixArgs(), and IdentifySubmatrixArgsInComputation().
void IdentifySubmatrixArgs | ( | std::vector< NnetComputation::Command > * | commands, |
std::vector< int32 * > * | submatrix_args | ||
) |
This function outputs to "submatrix_args" the addresses of the args (arguments arg1 through arg6) in the vector "commands", that correspond to the indexes of submatrices.
This is useful in renumbering code. Note: some of the pointers may point to a zero value, for optional submatrix args.
Definition at line 80 of file nnet-optimize-utils.cc.
References IdentifySubmatrixArgs().
void IdentifySubmatrixArgsInComputation | ( | NnetComputation * | computation, |
std::vector< int32 * > * | submatrix_args | ||
) |
This function outputs to "submatrix_args" the addresses of integers in 'computation' that correspond to submatrices.
These may be present in 'commands', and in 'indexes_multi'. This is useful in renumbering code. Note: some of the pointers may point to a zero value, for optional submatrix args in commands, but for efficiency we don't provide pointers for the -1's in 'indexes_multi'.
Definition at line 340 of file nnet-optimize-utils.cc.
References NnetComputation::commands, rnnlm::i, IdentifySubmatrixArgs(), and NnetComputation::indexes_multi.
Referenced by ComputationRenumberer::ComputeSubmatrixIsUsed(), and ComputationRenumberer::RenumberSubmatrices().
|
static |
Definition at line 2252 of file nnet-optimize-utils.cc.
References KALDI_ASSERT, and rnnlm::n.
Referenced by ReplaceRowWithMatrixOps().
|
static |
given a vector of pairs from computation.indexes_multi_indexes containing paris (submatrix-index, row-index), this function outputs to "submatrix_indexes" all (unique) submatrix indexes that appear; and it outputs to "contains_null_marker" true if the pair (-1, -1) appears anywhere in indexes_multi, and false otherwise.
Definition at line 264 of file nnet-analyze.cc.
References kaldi::SortAndUniq().
Referenced by ComputeCommandAttributes().
void InsertCommands | ( | std::vector< std::pair< int32, NnetComputation::Command > > * | commands, |
NnetComputation * | computation | ||
) |
Inserts commands into the computation at the requested places.
'commands' is a list of pairs (command-index, command) that is expected to be sorted on command-index. For each entry (c, command) in 'commands', 'command' is inserted into 'computation' just *before* the command that (at entry) is in computation->commands[c]. If there are multiple pairs with the same index c, they will remain in the same order in which they were present in 'commands'; however, 'commands' does not have to be sorted on 'c'. As a special case, if c == computation->commands.size(), the corresponding commands are inserted at the beginning of the computation. This function will appropriately renumber the argument of the kGotoLabel command of any 'looped' computation. Command indexes c in commands[*].first must be in the range [0, computation->commands.size()]. This function may modify 'commands' by sorting it.
Definition at line 4640 of file nnet-optimize-utils.cc.
References NnetComputation::commands, FixGotoLabel(), rnnlm::i, KALDI_ASSERT, and kaldi::RandInt().
Referenced by MemoryCompressionOptimizer::ModifyComputation(), and RowOpsSplitter::SplitCommands().
|
static |
Definition at line 3822 of file nnet-optimize-utils.cc.
References ConvertNumNValues(), FindNStride(), IoSpecification::has_deriv, IoSpecification::indexes, KALDI_ASSERT, and IoSpecification::name.
Referenced by RequestIsDecomposable().
|
static |
Definition at line 699 of file nnet-optimize-utils.cc.
References NnetComputation::Command::command_type, and kNoOperation.
Referenced by RemoveNoOps().
This function returns true if the nnet has the following properties: It has an output called "output" (other outputs are allowed but may be ignored).
It has an input called "input", and possibly an extra input called "ivector", but no other inputs. There are probably some other properties that we really ought to be checking, and we may add more later on.
Definition at line 52 of file nnet-utils.cc.
References Nnet::GetNodeIndex(), Nnet::IsInputNode(), Nnet::IsOutputNode(), and NumInputNodes().
Referenced by ComputeExampleComputationRequestSimple(), ComputeSimpleNnetContext(), DecodableNnetSimple::DecodableNnetSimple(), Nnet::Info(), DecodableNnetSimpleLoopedInfo::Init(), main(), NnetInfo(), and AmNnetSimple::SetContext().
BaseFloat kaldi::nnet3::KlDivergence | ( | const Vector< BaseFloat > & | p, |
const Vector< BaseFloat > & | q | ||
) |
Definition at line 31 of file nnet3-am-adjust-priors.cc.
References VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, KALDI_WARN, kaldi::Log(), and VectorBase< Real >::Sum().
Referenced by PrintPriorDiagnostics().
void kaldi::nnet3::LimitDerivativeTimes | ( | const Nnet & | nnet, |
const ComputationRequest & | request, | ||
const NnetOptimizeOptions & | opts, | ||
NnetComputation * | computation | ||
) |
This optimization, which has no effect unless you set –min-deriv-time or –max-deriv-time, modifies the backprop operations for efficiency based on the assumption that derivatives for any Cindex with t < min_deriv_time or t > max_deriv_time are zero.
(this is based on the fact that derivatives in recurrent setups will either decay to zero over time, or will explode and anyway become meaningless). This is only applied if you are not comoputing any input-derivatives). The assumption, for simple Components, is that backprop operations are no-ops as long as the input was zeroed, because the back-propagated derivatives would be zero and the model would not be updated.
The most important effect of this operation is to modify some operations of type kBackprop and kBackpropNoModelUpdate for simple Components, to either make them operate on row ranges of their original input (which in general will be newly created submatrices), or to remove them altogether if they do not operate on any 't' values within the correct range.
We assert as a requirement of this optimization that all allocation commands must zero their matrices (this effectively means that you cannot apply this optimization after RemoveUnnecessaryZeroing()). This means that we don't have to worry about leaving things undefined after removing backprop operations. We also assert that backprop commands that set instead of adding to their input, must not be outputting to things that were previously set to nonzero values. (this shouldn't ever be a problem, but we do check.
Note: after this optimization it will likely be beneficial to call RemoveUnnecessaryOperations to remove operations not of type kBackprop that have now become unnecessary– e.g. operations that do the backprop through Descriptors.
void LimitDerivativeTimes | ( | const Nnet & | nnet, |
int32 | min_deriv_time, | ||
int32 | max_deriv_time, | ||
NnetComputation * | computation | ||
) |
Definition at line 2215 of file nnet-optimize-utils.cc.
References DerivativeTimeLimiter::LimitDerivTimes().
Referenced by Optimize().
void MakeSccGraph | ( | const std::vector< std::vector< int32 > > & | graph, |
const std::vector< std::vector< int32 > > & | sccs, | ||
std::vector< std::vector< int32 > > * | scc_graph | ||
) |
Given a list of sccs of a graph (e.g.
as computed by FindSccs), compute a directed graph on the sccs. Of course this directed graph will be acyclic.
Definition at line 164 of file nnet-graph.cc.
References rnnlm::i, rnnlm::j, KALDI_ASSERT, and kaldi::SortAndUniq().
Referenced by ComputeNnetComputationEpochs(), and UnitTestMakeSccGraph().
bool MatrixIsUnused | ( | const Analyzer & | analyzer, |
const NnetComputation & | computation, | ||
int32 | m | ||
) |
This function returns true if matrix 1 <= m < computation->matrices.size() is unused, defined as: it is not an input or an output, and is not accessed other than via commands of type kAllocMatrix, kDeallocMatrix, and kSetConst.
Definition at line 4582 of file nnet-optimize-utils.cc.
References MatrixAccesses::accesses, NnetComputation::Command::command_type, NnetComputation::commands, rnnlm::i, MatrixAccesses::is_input, MatrixAccesses::is_output, kNoOperation, kSetConst, and Analyzer::matrix_accesses.
Referenced by DerivativeTimeLimiter::PruneMatrices().
int32 kaldi::nnet3::MaxMemoryUsage | ( | const NnetComputation & | computation | ) |
Returns the total memory, in bytes, used by the computation (just the temporary memory, not counting the memory used by the nnet itself).
This is defined as the maximum amount of memory used at any one instant.
int32 MaxOutputTimeInRequest | ( | const ComputationRequest & | request | ) |
Definition at line 484 of file nnet-optimize.cc.
References rnnlm::i, KALDI_ERR, and ComputationRequest::outputs.
Referenced by CompileLoopedInternal(), CachingOptimizingCompiler::CompileNoShortcut(), NnetOptimizeOptions::Register(), UnitTestNnetCompute(), and UnitTestNnetInputDerivatives().
void MergeChainExamples | ( | bool | compress, |
std::vector< NnetChainExample > * | input, | ||
NnetChainExample * | output | ||
) |
This function merges a list of NnetChainExample objects into a single one– intended to be used when forming minibatches for neural net training.
If 'compress' it compresses the output features (recommended to save disk space).
Note: the input is left as it was at the start, but it is temporarily changed inside the function; this is a trick to allow us to use the MergeExamples() routine while avoiding having to rewrite code.
Definition at line 256 of file nnet-chain-example.cc.
References rnnlm::i, NnetChainExample::inputs, NnetExample::io, rnnlm::j, KALDI_ASSERT, MergeExamples(), MergeSupervision(), and NnetChainExample::outputs.
Referenced by NnetChainExampleStructureCompare::operator()(), and ChainExampleMerger::WriteMinibatch().
void kaldi::nnet3::MergeDiscriminativeExamples | ( | std::vector< NnetDiscriminativeExample > * | input, |
bool | compress, | ||
NnetDiscriminativeExample * | output | ||
) |
Appends the given vector of examples (which must be non-empty) into a single output example.
Intended to be used when forming minibatches for neural net training. If 'compress' it compresses the output features (recommended to save disk space).
Note: the input is left as it was at the start, but it is temporarily changed inside the function; this is a trick to allow us to use the MergeExamples() routine while avoiding having to rewrite code.
void kaldi::nnet3::MergeDiscriminativeExamples | ( | bool | compress, |
std::vector< NnetDiscriminativeExample > * | input, | ||
NnetDiscriminativeExample * | output | ||
) |
Definition at line 247 of file nnet-discriminative-example.cc.
References rnnlm::i, NnetDiscriminativeExample::inputs, NnetExample::io, rnnlm::j, KALDI_ASSERT, MergeExamples(), MergeSupervision(), and NnetDiscriminativeExample::outputs.
Referenced by NnetDiscriminativeExampleStructureCompare::operator()(), and DiscriminativeExampleMerger::WriteMinibatch().
void MergeExamples | ( | const std::vector< NnetExample > & | src, |
bool | compress, | ||
NnetExample * | dest | ||
) |
Merge a set of input examples into a single example (typically the size of "src" will be the minibatch size).
Will crash if "src" is the empty vector. If "compress" is true, it will compress any non-sparse features in the output.
Definition at line 162 of file nnet-example-utils.cc.
References GetIoNames(), GetIoSizes(), KALDI_ASSERT, and MergeIo().
Referenced by MergeChainExamples(), MergeDiscriminativeExamples(), UnitTestNnetMergeExamples(), and ExampleMerger::WriteMinibatch().
|
static |
Definition at line 88 of file nnet-example-utils.cc.
References kaldi::AppendGeneralMatrixRows(), NnetIo::features, rnnlm::i, NnetIo::indexes, NnetExample::io, KALDI_ASSERT, rnnlm::n, and NnetIo::name.
Referenced by MergeExamples().
void MergeSupervision | ( | const std::vector< const NnetDiscriminativeSupervision *> & | inputs, |
NnetDiscriminativeSupervision * | output | ||
) |
Definition at line 185 of file nnet-discriminative-example.cc.
References NnetDiscriminativeSupervision::CheckDim(), NnetDiscriminativeSupervision::deriv_weights, VectorBase< Real >::Dim(), NnetDiscriminativeSupervision::indexes, KALDI_ASSERT, kaldi::kUndefined, kaldi::discriminative::MergeSupervision(), rnnlm::n, NnetDiscriminativeSupervision::name, NnetDiscriminativeSupervision::supervision, and DiscriminativeSupervision::Swap().
|
static |
Definition at line 195 of file nnet-chain-example.cc.
References NnetChainSupervision::CheckDim(), NnetChainSupervision::deriv_weights, VectorBase< Real >::Dim(), NnetChainSupervision::indexes, KALDI_ASSERT, kaldi::kUndefined, rnnlm::n, NnetChainSupervision::name, and NnetChainSupervision::supervision.
Referenced by MergeChainExamples(), MergeDiscriminativeExamples(), and NnetDiscriminativeExampleStructureCompare::operator()().
void MergeTaskOutput | ( | const std::vector< NnetInferenceTask > & | tasks, |
Matrix< BaseFloat > * | output | ||
) |
Merges together the 'output_cpu' (if the 'output_to_cpu' members are true) or the 'output' members of 'tasks' into a single CPU matrix 'output'.
Requires that those outputs are nonempty (i.e. that those tasks must have been completed).
[in] | tasks | The vector of tasks whose outputs are to be merged. The tasks must have already been completed. |
[output | output The spliced-together output matrix |
TODO: in the future, maybe start from GPU and use pinned matrices for the transfer.
Definition at line 968 of file nnet-batch-compute.cc.
References NnetInferenceTask::first_used_output_frame_index, rnnlm::i, KALDI_ASSERT, NnetInferenceTask::num_initial_unused_output_frames, NnetInferenceTask::num_used_output_frames, MatrixBase< Real >::NumCols(), NnetInferenceTask::output, NnetInferenceTask::output_cpu, NnetInferenceTask::output_to_cpu, Matrix< Real >::Resize(), and MatrixBase< Real >::RowRange().
Referenced by NnetBatchInference::GetOutput(), and NnetBatchComputerOptions::Register().
void MergeTaskOutput | ( | const std::vector< NnetInferenceTask > & | tasks, |
CuMatrix< BaseFloat > * | output | ||
) |
Definition at line 1002 of file nnet-batch-compute.cc.
References CuMatrixBase< Real >::Data(), NnetInferenceTask::first_used_output_frame_index, rnnlm::i, KALDI_ASSERT, kaldi::kUndefined, NnetInferenceTask::num_initial_unused_output_frames, NnetInferenceTask::num_used_output_frames, MatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), NnetInferenceTask::output, NnetInferenceTask::output_cpu, NnetInferenceTask::output_to_cpu, CuMatrix< Real >::Resize(), MatrixBase< Real >::RowRange(), CuMatrixBase< Real >::RowRange(), and CuMatrixBase< Real >::Stride().
I kaldi::nnet3::Mod | ( | I | m, |
I | n | ||
) |
Mod(m, n), defined for integers m and n where n > 0, returns the modulus m % n, defined as the integer 0 <= i < n such that i and m are congruent modulo n; for instance, Mod(13, 10) = 3.
This is like the % operation in C/C++, except that it always returns a positive value even for negative m; in 99% of cases where it makes a difference, this is what you want. In the C/C++ standard, the sign of a % b for negative a is not specified (except by relation with the division '/' operator), but in practice it would be <= 0 for almost all implementations.
Definition at line 106 of file nnet-compile-looped.cc.
References rnnlm::n.
Referenced by CreateLoopedComputationRequest().
This function modifies the descriptors in the neural network to change the periodicity with which it expects to read an iVector at its input.
We normally train neural networks that expect to see an iVector at frame zero only; this is because we train on fixed-size chunks and the iVector doesn't change that much within each chunk. However, expecting just one iVector isn't that convenient for looped recognition because it changes with time, so we modify the iVector input period in the network by replacing expressions like ReplaceIndex(ivector, t, 0) with Round(ivector, 10) [assuming ivector_period == 10]. The descriptor doesn't have to be named "ivector", it would work for ReplaceIndex(foo, t, 0). This won't work in every conceivable network, but it does do what you want in the cases of interest.
It does this in a rather simple way, by getting the config lines that correspond to descriptors, and doing a search-and-replace. It's maybe not ideal, but it was the easiest way to do it.
Definition at line 28 of file nnet-compile-looped.cc.
References ConfigLine::FirstToken(), Nnet::GetConfigLines(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, ConfigLine::ParseLine(), and Nnet::ReadConfig().
Referenced by DecodableNnetSimpleLoopedInfo::Init(), and UnitTestNnetCompileLooped().
void MoveSizingCommands | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This optimization moves commands that allocate and zero matrices to as late as possible, and moves commands that deallocate matrices to as early as possible.
Definition at line 152 of file nnet-optimize.cc.
References MatrixAccesses::accesses, MatrixAccesses::allocate_command, NnetComputation::Command::command_type, NnetComputation::commands, ComputeCommandAttributes(), ComputeMatrixAccesses(), ComputeVariableAccesses(), MatrixAccesses::deallocate_command, ComputationVariables::Init(), KALDI_ASSERT, kAllocMatrix, kDeallocMatrix, kGotoLabel, and kSetConst.
Referenced by Optimize().
bool NameMatchesPattern | ( | const char * | name, |
const char * | pattern | ||
) |
Definition at line 235 of file nnet-parse.cc.
Referenced by SvdApplier::DecomposeComponents(), ReadEditConfig(), ReduceRankOfComponents(), and UnitTestNameMatchesPattern().
std::string NnetInfo | ( | const Nnet & | nnet | ) |
This function returns various info about the neural net.
If the nnet satisfied IsSimpleNnet(nnet), the info includes "left-context=5\nright-context=3\n...". The info includes the output of nnet.Info(). This is modeled after the info that AmNnetSimple returns in its Info() function (we need this in the CTC code).
Definition at line 492 of file nnet-utils.cc.
References ComputeSimpleNnetContext(), Nnet::Info(), Nnet::InputDim(), IsSimpleNnet(), and Nnet::OutputDim().
Referenced by UnitTestNnetContext().
Returns true if 'nnet' has some kind of recurrency.
Definition at line 1441 of file nnet-utils.cc.
References GraphHasCycles(), and NnetToDirectedGraph().
Referenced by TestNnetDecodable(), UnitTestNnetInputDerivatives(), and UnitTestNnetModelDerivatives().
Used for testing that the updatable parameters in two networks are the same.
May crash if structure differs. Prints warning and returns false if parameters differ. E.g. set threshold to 1.0e-05 (it's a relative threshold, applied per component).
Definition at line 1802 of file nnet-test-utils.cc.
References UpdatableComponent::DotProduct(), Nnet::GetComponent(), Nnet::GetComponentName(), KALDI_ASSERT, KALDI_WARN, kUpdatableComponent, Nnet::NumComponents(), Component::Properties(), and Component::Type().
Referenced by NnetGenerationOptions::NnetGenerationOptions(), and UnitTestNnetOptimizeWithOptions().
This function takes an nnet and turns it to a directed graph on nodes.
This is the reverse of the dependency graph. The nodes will be numbered from 0 to graph->size() - 1, where graph->size() == nnet.NumNodes(). For each node-index n, the vector in (*graph)[n] will contain a list of all the nodes that have a direct dependency on node n (in order to compute them). For instance, if n is the output node, (*graph)[n] will be the empty list because no other node will depend on it.
Definition at line 30 of file nnet-graph.cc.
References NetworkNode::descriptor, Nnet::GetNode(), Descriptor::GetNodeDependencies(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, kComponent, kDescriptor, kDimRange, kInput, rnnlm::n, NetworkNode::node_index, NetworkNode::node_type, Nnet::NumNodes(), kaldi::SortAndUniq(), and NetworkNode::u.
Referenced by ComputeNnetComputationEpochs(), FindOrphanNodes(), and NnetIsRecurrent().
std::string kaldi::nnet3::NormalizeTextDescriptor | ( | const std::vector< std::string > & | node_names, |
const std::string & | desc_str | ||
) |
Definition at line 180 of file nnet-descriptor-test.cc.
References GeneralDescriptor::ConvertToDescriptor(), DescriptorTokenize(), KALDI_ERR, KALDI_LOG, GeneralDescriptor::Parse(), and Descriptor::WriteConfig().
Referenced by UnitTestGeneralDescriptorSpecial().
returns the number of input nodes of this nnet.
Definition at line 43 of file nnet-utils.cc.
References Nnet::IsInputNode(), rnnlm::n, and Nnet::NumNodes().
Referenced by IsSimpleNnet().
int32 kaldi::nnet3::NumOutputIndexes | ( | const NnetExample & | eg | ) |
Definition at line 32 of file nnet3-merge-egs.cc.
References rnnlm::i, and NnetExample::io.
returns the number of output nodes of this nnet.
Definition at line 35 of file nnet-utils.cc.
References Nnet::IsOutputNode(), rnnlm::n, and Nnet::NumNodes().
Returns the total of the number of parameters in the updatable components of the nnet.
Definition at line 359 of file nnet-utils.cc.
References Nnet::GetComponent(), KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), UpdatableComponent::NumParameters(), and Component::Properties().
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), Nnet::Info(), ConstantComponent::IsComputable(), LinearComponent::LinearComponent(), main(), AffineComponent::Properties(), BlockAffineComponent::Properties(), RepeatedAffineComponent::Properties(), PerElementScaleComponent::Properties(), PerElementOffsetComponent::Properties(), ConstantFunctionComponent::Properties(), CompositeComponent::Type(), LstmNonlinearityComponent::UnVectorize(), UnVectorizeNnet(), UpdateNnetMovingAverage(), LstmNonlinearityComponent::Vectorize(), and VectorizeNnet().
Returns the number of updatable components in the nnet.
Definition at line 422 of file nnet-utils.cc.
References Nnet::GetComponent(), kUpdatableComponent, Nnet::NumComponents(), and Component::Properties().
Referenced by kaldi::nnet2::CombineNnets(), FastNnetCombiner::CombineNnets(), kaldi::nnet2::CombineNnetsA(), FastNnetCombiner::ComputeCurrentNnet(), kaldi::nnet2::GetUpdateDirection(), main(), PrintVectorPerUpdatableComponent(), and UpdateNnetWithMaxChange().
std::ostream & operator<< | ( | std::ostream & | os, |
const ComputationGraphBuilder::ComputableInfo & | info | ||
) |
This is to be used in logging only.
Definition at line 318 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::kComputable, ComputationGraphBuilder::kNotComputable, and ComputationGraphBuilder::kUnknown.
std::ostream & operator<< | ( | std::ostream & | ostream, |
const Index & | index | ||
) |
Definition at line 424 of file nnet-common.cc.
References Index::n, Index::t, and Index::x.
Referenced by IndexLessNxt::operator()().
std::ostream & operator<< | ( | std::ostream & | ostream, |
const Cindex & | cindex | ||
) |
Definition at line 428 of file nnet-common.cc.
void Optimize | ( | const NnetOptimizeOptions & | config, |
const Nnet & | nnet, | ||
int32 | max_output_time_in_request, | ||
NnetComputation * | computation | ||
) |
This is the top-level function for optimizing a computation.
Note: it should really be called OptimizeAndPostprocess(), because there is at least one thing it does (reordering I/O commands) that is necessary for a computation to be run.
[in] | config | The options that control, among other things, which optimizations to apply. |
[in] | nnet | The neural net for which the computation is being built |
[in] | max_output_time_in_request | This value is only needed when the max-deriv-time-relative config value is set in 'config'. It should be set to the largest 't' value encountered in any of the indexes in the 'output' IoSpecifications in the ComputationRequests used to compile the computation. However if there are multiple ComputationRequests (i.e. it was an online computation) you can just set it to any value you want, because backpropagation is not supported so the max-deriv-time-relative configuration value would not have any effect. |
[in,out] | computation | The computation to be optimized; this function modifies it in-place. |
Definition at line 501 of file nnet-optimize.cc.
References NnetOptimizeOptions::allocate_from_other, NnetOptimizeOptions::backprop_in_place, CheckComputation(), NnetOptimizeOptions::consolidate_model_update, ConsolidateIoOperations(), ConsolidateModelUpdate(), NnetOptimizeOptions::convert_addition, ConvertAdditionToAssignment(), NnetOptimizeOptions::extend_matrices, ExtendMatrices(), FixGotoLabel(), GetMaxMemoryUse(), kaldi::GetVerboseLevel(), NnetOptimizeOptions::initialize_undefined, KALDI_LOG, LimitDerivativeTimes(), NnetOptimizeOptions::max_deriv_time, NnetOptimizeOptions::max_deriv_time_relative, NnetOptimizeOptions::memory_compression_level, NnetOptimizeOptions::min_deriv_time, NnetOptimizeOptions::move_sizing_commands, MoveSizingCommands(), NnetOptimizeOptions::optimize, NnetOptimizeOptions::optimize_looped_computation, NnetOptimizeOptions::optimize_row_ops, OptimizeLoopedComputation(), OptimizeMemoryCompression(), NnetOptimizeOptions::propagate_in_place, NnetOptimizeOptions::remove_assignments, RemoveUnnecessaryAllocation(), RemoveUnnecessaryZeroing(), RenumberComputation(), ReplaceRowWithMatrixOps(), NnetOptimizeOptions::snip_row_ops, SnipRowOps(), NnetOptimizeOptions::split_row_ops, SplitRowOps(), and VariableMergingOptimization().
Referenced by CompileLoopedInternal(), CachingOptimizingCompiler::CompileNoShortcut(), ComputationLoopedOptimizer::ComputationLoopedOptimizer(), MemoryCompressionOptimizer::MemoryCompressionOptimizer(), NnetOptimizeOptions::Register(), UnitTestNnetCompute(), and UnitTestNnetInputDerivatives().
void OptimizeLoopedComputation | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This function tries to optimize computation 'computation' for an 'looped' computation.
It expects as input a computation with no backprop but with multiple 'segments' separated by command kNoOperationLabel, where each segment corresponds to a new chunk of input and output. It tries to locate a pair of segment boundaries, with command indexes c1 and c2, where the active matrices have the same debug-info other than a time offset and can be identified with each other, and the no-op command at c2 can be replaced with 'got c1', creating a computation that 'goes on forever'. If it can't do this, it does nothing. You can figure out that this is the case by checking whether kGotoLabel is the last command in the computation. [If this optimization fails, the whole computation may have to be regenerated with more segments.]
Definition at line 4544 of file nnet-optimize-utils.cc.
References ComputationLoopedOptimizer::Optimize().
Referenced by Optimize().
void OptimizeMemoryCompression | ( | const Nnet & | nnet, |
int32 | memory_compression_level, | ||
NnetComputation * | computation | ||
) |
Performs optimization to reduce memory usage where possible, making use of the kCompressMatrix and kDecompressMatrix commands.
Should only be done after most other optimizations, because some optimizations (such as variable-merging) would not work correctly after doing this optimization. This does nothing for looped computations. It's OK, though, to expand a shortcut computation (i.e. call ExpandComputation) after doing this.
memory_compression_level determines how aggressive the compression is. Allowed values: 0 = no compression at all 1 = compression that doesn't affect results (e.g. compress ReLU outputs to 1 byte, as just the sign is needed). 2 = compression that may affect the results slightly (e.g. 16-bit compression of the output of NormalizeComponent and the like), but this is not implemented yet, so equivalent to 1. 3 = compression that may affect the results more than just slightly. Not implemented yet, so equivalent to 1.
Definition at line 4899 of file nnet-optimize-utils.cc.
References NnetComputation::commands, GetMaxMemoryUse(), kaldi::GetVerboseLevel(), rnnlm::i, KALDI_VLOG, KALDI_WARN, kGotoLabel, kNoOperationMarker, and MemoryCompressionOptimizer::Optimize().
Referenced by Optimize().
void kaldi::nnet3::ParseConfigLines | ( | const std::vector< std::string > & | lines, |
std::vector< ConfigLine > * | config_lines | ||
) |
Definition at line 224 of file nnet-parse.cc.
References rnnlm::i, and KALDI_ERR.
Referenced by Nnet::ReadConfig(), and ReadEditConfig().
|
static |
Definition at line 29 of file nnet-descriptor.cc.
Referenced by ExpectToken(), and ReadIntegerToken().
void kaldi::nnet3::PerturbImage | ( | const ImageAugmentationConfig & | config, |
MatrixBase< BaseFloat > * | image | ||
) |
This function randomly modifies (perturbs) the image by applying different geometric transformations according to the options in 'config'.
References: "Digital Image Processing book by Gonzalez and Woods" and "Keras: github.com/fchollet/keras/blob/master/keras/preprocessing/image.py"
[in] | config | Configuration class that says how to perturb the image. |
[in,out] | image | The image matrix to be modified. image->NumRows() is the width (number of x values) in the image; image->NumCols() is the height times number of channels/colors (channel varies the fastest). |
Definition at line 205 of file nnet3-egs-augment-image.cc.
References MatrixBase< Real >::AddMatMat(), MatrixBase< Real >::AddMatMatMat(), ApplyAffineTransform(), ImageAugmentationConfig::Check(), ImageAugmentationConfig::GetFillMode(), ImageAugmentationConfig::horizontal_flip_prob, ImageAugmentationConfig::horizontal_shift, MatrixBase< Real >::IsUnit(), KALDI_ERR, kaldi::kNoTrans, kaldi::kUndefined, M_PI, ImageAugmentationConfig::num_channels, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), kaldi::RandUniform(), ImageAugmentationConfig::rotation_degree, ImageAugmentationConfig::rotation_prob, MatrixBase< Real >::SetUnit(), ImageAugmentationConfig::vertical_shift, and kaldi::WithProb().
Referenced by PerturbImageInNnetExample().
void kaldi::nnet3::PerturbImageInNnetExample | ( | const ImageAugmentationConfig & | config, |
NnetExample * | eg | ||
) |
This function does image perturbation as directed by 'config' The example 'eg' is expected to contain a NnetIo member with the name 'input', representing an image.
Definition at line 302 of file nnet3-egs-augment-image.cc.
References NnetIo::features, GeneralMatrix::GetMatrix(), rnnlm::i, NnetExample::io, KALDI_ERR, NnetIo::name, and PerturbImage().
Referenced by main().
Calls PerturbParams (with the given stddev) on all updatable components of the nnet.
Definition at line 199 of file nnet-utils.cc.
References Nnet::GetComponent(), KALDI_ASSERT, kUpdatableComponent, Nnet::NumComponents(), UpdatableComponent::PerturbParams(), and Component::Properties().
Referenced by AffineComponent::BackpropNeedsOutput(), BlockAffineComponent::BackpropNeedsOutput(), Convolutional1dComponent::BackpropNeedsOutput(), LstmNonlinearityComponent::ConsolidateMemory(), ScaleAndOffsetComponent::Copy(), ConstantComponent::IsComputable(), LinearComponent::LinearComponent(), AffineComponent::Properties(), BlockAffineComponent::Properties(), RepeatedAffineComponent::Properties(), PerElementScaleComponent::Properties(), PerElementOffsetComponent::Properties(), ConstantFunctionComponent::Properties(), CompositeComponent::Type(), UnitTestNnetModelDerivatives(), and UpdatableComponent::~UpdatableComponent().
void PrintCindex | ( | std::ostream & | os, |
const Cindex & | cindex, | ||
const std::vector< std::string > & | node_names | ||
) |
Definition at line 432 of file nnet-common.cc.
References KALDI_ASSERT.
Referenced by ComputationGraph::Print().
void PrintCindexes | ( | std::ostream & | ostream, |
const std::vector< Cindex > & | cindexes, | ||
const std::vector< std::string > & | node_names | ||
) |
this will only be used for pretty-printing.
It prints a vector of Cindexes in a compact, human-readable way with compression of ranges. If the values of the node indexes are the same for the entire vector, it will just be node-name followed by the output of PrintIndexes, e.g. some_node[ (1,1,0) ]. Otherwise it will divide the vector into ranges that each have all the same node name, and will print out each range in the way we just mentioned. 'node_names' will usually come from a call like nnet.GetNodeNames().
Definition at line 498 of file nnet-common.cc.
References KALDI_ASSERT, and PrintIndexes().
Referenced by PrintComputationPreamble().
Definition at line 28 of file nnet-analyze-test.cc.
Referenced by NnetComputation::GetCommandStrings(), NnetComputation::Print(), and UnitTestNnetAnalyze().
|
static |
Definition at line 513 of file nnet-computation.cc.
References NnetComputation::Command::alpha, NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::arg4, NnetComputation::Command::arg5, NnetComputation::Command::arg6, NnetComputation::Command::command_type, NnetComputation::commands, Nnet::GetComponentName(), Nnet::GetNodeName(), rnnlm::i, NnetComputation::indexes_ranges, kAcceptInput, kAddRowRanges, kAddRows, kAddRowsMulti, kAddToRowsMulti, KALDI_ASSERT, KALDI_ERR, kAllocMatrix, kBackprop, kBackpropNoModelUpdate, kaldi::kCompressedMatrixInt16, kaldi::kCompressedMatrixInt8, kaldi::kCompressedMatrixUint8, kCompressMatrix, kCopyRows, kCopyRowsMulti, kCopyToRowsMulti, kDeallocMatrix, kDecompressMatrix, kGotoLabel, kMatrixAdd, kMatrixCopy, kNoOperation, kNoOperationLabel, kNoOperationMarker, kNoOperationPermanent, kPropagate, kProvideOutput, kSetConst, kSwapMatrix, NnetComputation::need_model_derivative, and NnetComputation::submatrices.
void PrintCommandAttributes | ( | std::ostream & | os, |
const std::vector< CommandAttributes > & | attributes | ||
) |
This function is to be used in debugging; it produces human-readable output.
Definition at line 1368 of file nnet-analyze.cc.
References CommandAttributes::matrices_read, CommandAttributes::matrices_written, CommandAttributes::variables_read, and CommandAttributes::variables_written.
Referenced by CommandAttributes::CommandAttributes().
|
static |
Definition at line 684 of file nnet-computation.cc.
References NnetComputation::MatrixDebugInfo::cindexes, Nnet::GetNodeNames(), rnnlm::i, NnetComputation::MatrixDebugInfo::is_deriv, KALDI_ASSERT, NnetComputation::matrices, NnetComputation::matrix_debug_info, and PrintCindexes().
Referenced by NnetComputation::GetCommandStrings(), and NnetComputation::Print().
|
static |
std::string PrintGraphToString | ( | const std::vector< std::vector< int32 > > & | graph | ) |
Prints a graph to a string in a pretty way for human readability, e.g.
as 0 -> 1,2; 1 -> 2; 2 -> 3,4,5; etc.
Definition at line 248 of file nnet-graph.cc.
References rnnlm::i, and rnnlm::j.
Referenced by ComputeNnetComputationEpochs().
void PrintIndexes | ( | std::ostream & | ostream, |
const std::vector< Index > & | indexes | ||
) |
this will only be used for pretty-printing.
It prints a vector of Indexes in a compact, human-readable way with compression of ranges (it also doesn't print the x index if it's 1.0. Example output: "[ (1,1:20), (2, 1:20) ]" which would correspond to the indexes [ (1,1,0), (1,2,0) ... (1,20,0) (2,1,0) ... (2,20,0) ].
Definition at line 442 of file nnet-common.cc.
References rnnlm::i, KALDI_ASSERT, Index::n, Index::t, and Index::x.
Referenced by IoSpecification::Print(), and PrintCindexes().
void PrintIntegerVector | ( | std::ostream & | os, |
const std::vector< int32 > & | ints | ||
) |
Definition at line 525 of file nnet-common.cc.
References rnnlm::i, and KALDI_ASSERT.
Referenced by kaldi::nnet3::computation_graph::ComputeEpochInfo(), and GetIndexesStrings().
void PrintMatrixAccesses | ( | std::ostream & | os, |
const std::vector< MatrixAccesses > & | matrix_accesses | ||
) |
This function is to be used in debugging; it produces human-readable output.
Definition at line 1350 of file nnet-analyze.cc.
References MatrixAccesses::accesses, MatrixAccesses::allocate_command, MatrixAccesses::deallocate_command, kReadAccess, and kWriteAccess.
Referenced by MatrixAccesses::MatrixAccesses().
void PrintParameterStats | ( | std::ostringstream & | os, |
const std::string & | name, | ||
const CuVectorBase< BaseFloat > & | params, | ||
bool | include_mean = false |
||
) |
Print to 'os' some information about the mean and standard deviation of some parameters, used in Info() functions in nnet-simple-component.cc.
For example: PrintParameterStats(os, "bias", bias_params_, true); would print to 'os' something like the string ", bias-{mean,stddev}=-0.013,0.196". If 'include_mean = false', it will print something like ", bias-rms=0.2416", and this represents and uncentered standard deviation.
Definition at line 157 of file nnet-parse.cc.
References CuVectorBase< Real >::Dim(), CuVectorBase< Real >::Sum(), and kaldi::VecVec().
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), ConvolutionComponent::Info(), TimeHeightConvolutionComponent::Info(), LstmNonlinearityComponent::Info(), AffineComponent::Info(), TdnnComponent::Info(), BlockAffineComponent::Info(), RepeatedAffineComponent::Info(), ConstantComponent::Info(), LinearComponent::Info(), FixedAffineComponent::Info(), FixedScaleComponent::Info(), FixedBiasComponent::Info(), PerElementScaleComponent::Info(), PerElementOffsetComponent::Info(), ConstantFunctionComponent::Info(), and ScaleAndOffsetComponent::Info().
void PrintParameterStats | ( | std::ostringstream & | os, |
const std::string & | name, | ||
const CuMatrix< BaseFloat > & | params, | ||
bool | include_mean = false , |
||
bool | include_row_norms = false , |
||
bool | include_column_norms = false , |
||
bool | include_singular_values = false |
||
) |
Print to 'os' some information about the mean and standard deviation of some parameters, used in Info() functions in nnet-simple-component.cc.
For example: PrintParameterStats(os, "linear-params", linear_params_; would print to 'os' something like the string ", linear-params-rms=0.239". If you set 'include_mean' to true, it will print something like ", linear-params-{mean-stddev}=0.103,0.183". If you set 'include_row_norms' to true, it will print something like ", linear-params-row-norms=[percentiles(0,1........, stddev=0.0508]" If you set 'include_column_norms' to true, it will print something like ", linear-params-col-norms=[percentiles(0,1........, stddev=0.0508]" If you set 'include_singular_values' to true, it will print something like ", linear-params-singular-values=[percentiles(0,1........, stddev=0.0508]"
Definition at line 174 of file nnet-parse.cc.
References CuVectorBase< Real >::AddDiagMat2(), kaldi::kNoTrans, kaldi::kTrans, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), CuMatrixBase< Real >::Sum(), SummarizeVector(), MatrixBase< Real >::Svd(), Vector< Real >::Swap(), and kaldi::TraceMatMat().
void kaldi::nnet3::PrintPriorDiagnostics | ( | const Vector< BaseFloat > & | old_priors, |
const Vector< BaseFloat > & | new_priors | ||
) |
Definition at line 48 of file nnet3-am-adjust-priors.cc.
References VectorBase< Real >::AddVec(), VectorBase< Real >::ApplyAbs(), VectorBase< Real >::Dim(), KALDI_LOG, KlDivergence(), and VectorBase< Real >::Max().
Referenced by main().
std::string PrintVectorPerUpdatableComponent | ( | const Nnet & | nnet, |
const VectorBase< BaseFloat > & | vec | ||
) |
This function is for printing, to a string, a vector with one element per updatable component of the nnet (e.g.
the output of ComponentDotProducts), in a human readable way, as [ component-name1:number1 component-name2:number2 ... ].
Definition at line 231 of file nnet-utils.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), Nnet::GetComponentName(), KALDI_ASSERT, kUpdatableComponent, Nnet::NumComponents(), NumUpdatableComponents(), and Component::Properties().
Referenced by main().
void kaldi::nnet3::PrintVectorVectorPair | ( | std::vector< std::vector< std::pair< int32, int32 > > > | vec_vec_pair | ) |
Definition at line 50 of file nnet-compile-utils-test.cc.
References rnnlm::i, rnnlm::j, and KALDI_LOG.
Referenced by UnitTestSplitLocations(), and UnitTestSplitLocationsBackward().
|
static |
Definition at line 33 of file nnet3-get-egs.cc.
References NnetExample::Compress(), UtteranceSplitter::Config(), kaldi::ExtractRowRangeWithPadding(), ChunkTimeInfo::first_frame, ExampleGenerationConfig::frame_subsampling_factor, UtteranceSplitter::GetChunksForUtterance(), rnnlm::i, NnetExample::io, KALDI_WARN, ChunkTimeInfo::left_context, UtteranceSplitter::LengthsMatch(), ChunkTimeInfo::num_frames, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), GeneralMatrix::NumRows(), ChunkTimeInfo::output_weights, kaldi::RandInt(), ChunkTimeInfo::right_context, MatrixBase< Real >::Row(), and TableWriter< Holder >::Write().
|
static |
Definition at line 34 of file nnet3-get-egs-dense-targets.cc.
References NnetExample::Compress(), UtteranceSplitter::Config(), VectorBase< Real >::CopyFromVec(), kaldi::ExtractRowRangeWithPadding(), ChunkTimeInfo::first_frame, ExampleGenerationConfig::frame_subsampling_factor, UtteranceSplitter::GetChunksForUtterance(), rnnlm::i, NnetExample::io, KALDI_ASSERT, KALDI_WARN, ChunkTimeInfo::left_context, UtteranceSplitter::LengthsMatch(), ChunkTimeInfo::num_frames, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), GeneralMatrix::NumRows(), kaldi::RandInt(), ChunkTimeInfo::right_context, MatrixBase< Real >::Row(), and TableWriter< Holder >::Write().
|
static |
Definition at line 39 of file nnet3-discriminative-get-egs.cc.
References NnetDiscriminativeExample::Compress(), UtteranceSplitter::Config(), VectorBase< Real >::CopyFromVec(), ChunkTimeInfo::first_frame, ExampleGenerationConfig::frame_subsampling_factor, DiscriminativeSupervision::frames_per_sequence, UtteranceSplitter::GetChunksForUtterance(), DiscriminativeSupervisionSplitter::GetFrameRange(), NnetDiscriminativeExample::inputs, rnnlm::j, KALDI_ASSERT, KALDI_WARN, kaldi::kUndefined, ChunkTimeInfo::left_context, UtteranceSplitter::LengthsMatch(), ChunkTimeInfo::num_frames, DiscriminativeSupervision::num_sequences, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), ChunkTimeInfo::output_weights, NnetDiscriminativeExample::outputs, kaldi::RandInt(), ChunkTimeInfo::right_context, MatrixBase< Real >::Row(), and TableWriter< Holder >::Write().
Referenced by main().
|
static |
Definition at line 41 of file nnet3-xvector-get-egs.cc.
References kaldi::ConvertStringToInteger(), KALDI_ERR, ChunkInfo::label, ChunkInfo::name, ChunkInfo::num_frames, ChunkInfo::output_archive_id, kaldi::SplitStringToVector(), ChunkInfo::start_frame, and Input::Stream().
Referenced by main().
Definition at line 309 of file nnet-common.cc.
References ExpectToken(), rnnlm::i, KALDI_ERR, kaldi::ReadBasicType(), and ReadCindexVectorElementBinary().
Referenced by NnetComputation::MatrixDebugInfo::Read(), and UnitTestCindexIo().
|
static |
Definition at line 224 of file nnet-common.cc.
References rnnlm::i, KALDI_ASSERT, KALDI_ERR, Index::n, kaldi::ReadBasicType(), Index::t, and Index::x.
Referenced by ReadCindexVector().
void ReadEditConfig | ( | std::istream & | config_file, |
Nnet * | nnet | ||
) |
ReadEditConfig() reads a file with a similar-looking format to the config file read by Nnet::ReadConfig(), but this consists of a sequence of operations to perform on an existing network, mostly modifying components.
It's one "directive" (i.e. command) per line, but if supplying the options via the –edits option to programs like nnet3-am-copy, you can use a semicolon in place of the newline to separate commands.
The following describes the allowed commands. Note: all patterns are like UNIX globbing patterns where the only metacharacter is '*', representing zero or more characters.
convert-to-fixed-affine [name=<name-pattern>] Converts the given affine components to FixedAffineComponent which is not updatable. remove-orphan-nodes [remove-orphan-inputs=(true|false)] Removes orphan nodes (that are never used to compute anything). Note: remove-orphan-inputs defaults to false. remove-orphan-components Removes orphan components (those that are never used by any node). remove-orphans [remove-orphan-inputs=(true|false)] The same as calling remove-orphan-nodes and then remove-orphan-components. set-learning-rate [name=<name-pattern>] learning-rate=<learning-rate> Sets the learning rate for any updatable components matching the name pattern. Note: this sets the 'underlying' learning rate, i.e. it will get multiplied by any 'learning-rate-factor' set in the components. set-learning-rate-factor [name=<name-pattern>] learning-rate-factor=<learning-rate-factor> Sets the learning rate factor for any updatable components matching the name pattern. rename-node old-name=<old-name> new-name=<new-name> Renames a node; this is a surface renaming that does not affect the structure (for structural changes, use the regular config file format, not the edits-config). This is mostly useful for outputs, e.g. when doing multilingual experiments. remove-output-nodes name=<name-pattern> Removes a subset of output nodes, those matching the pattern. You cannot remove internal nodes directly; instead you should use the command 'remove-orphans'. set-dropout-proportion [name=<name-pattern>] proportion=<dropout-proportion> Sets the dropout rates for any components of type DropoutComponent, DropoutMaskComponent or GeneralDropoutComponent whose names match the given <name-pattern> (e.g. lstm*). <name-pattern> defaults to "*". apply-svd name=<name-pattern> bottleneck-dim=<dim> energy-threshold=<threshold> shrinkage-threshold=<s> Locates all components with names matching <name-pattern>, which are type AffineComponent or child classes thereof. If <dim> is less than the minimum of the (input or output) dimension of the component, it does SVD on the components' parameters, retaining only the largest <dim> singular values, replacing these components with sequences of two components, of types LinearComponent and NaturalGradientAffineComponent. Instead we can set the filtering criterion for the Singular values as energy-threshold, and retain those values which contribute to energy-threshold times the total energy of the original singular values. A particular SVD factored component is left unshrinked, if the shrinkage ratio of the total no. of its parameters, after the SVD based refactoring, is greater than shrinkage threshold. See also 'reduce-rank'. reduce-rank name=<name-pattern> rank=<dim> Locates all components with names matching <name-pattern>, which are type AffineComponent or child classes thereof. Does SVD on the components' parameters, retaining only the largest <dim> singular values, and writes the reconstructed matrix back to the component. See also 'apply-svd', which structurally breaks the component into two pieces.
Definition at line 1234 of file nnet-utils.cc.
References SvdApplier::ApplySvd(), ConfigLine::FirstToken(), Nnet::GetComponent(), Nnet::GetComponentName(), Nnet::GetNodeIndex(), Nnet::GetNodeName(), ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), rnnlm::i, Nnet::IsOutputNode(), KALDI_ERR, KALDI_LOG, rnnlm::n, NameMatchesPattern(), Nnet::NumComponents(), Nnet::NumNodes(), ParseConfigLines(), kaldi::ReadConfigLines(), ReduceRankOfComponents(), Nnet::RemoveOrphanComponents(), Nnet::RemoveOrphanNodes(), Nnet::RemoveSomeNodes(), Nnet::SetComponent(), DropoutComponent::SetDropoutProportion(), DropoutMaskComponent::SetDropoutProportion(), GeneralDropoutComponent::SetDropoutProportion(), UpdatableComponent::SetLearningRateFactor(), Nnet::SetNodeName(), UpdatableComponent::SetUnderlyingLearningRate(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
Referenced by CollapseModelConfig::CollapseModelConfig(), and main().
Definition at line 143 of file nnet-common.cc.
References ExpectToken(), rnnlm::i, KALDI_ERR, kaldi::ReadBasicType(), and ReadIndexVectorElementBinary().
Referenced by IndexLessNxt::operator()(), NnetIo::Read(), NnetDiscriminativeSupervision::Read(), IoSpecification::Read(), NnetChainSupervision::Read(), NnetComputation::Read(), and UnitTestIndexIo().
|
static |
Definition at line 87 of file nnet-common.cc.
References rnnlm::i, KALDI_ERR, Index::n, kaldi::ReadBasicType(), Index::t, and Index::x.
Referenced by ReadIndexVector().
|
static |
Definition at line 56 of file nnet-descriptor.cc.
References kaldi::ConvertStringToInteger(), KALDI_ERR, and ParsingContext().
Referenced by GeneralDescriptor::ParseOffset(), GeneralDescriptor::ParseReplaceIndex(), and GeneralDescriptor::ParseRound().
Definition at line 258 of file nnet-example-utils.cc.
References VectorBase< Real >::Data(), rnnlm::i, kaldi::kUndefined, Vector< Real >::Read(), kaldi::ReadIntegerVector(), and Vector< Real >::Resize().
Referenced by NnetDiscriminativeSupervision::Read(), and NnetChainSupervision::Read().
void kaldi::nnet3::RearrangeIndexes | ( | const std::vector< std::vector< int32 > > & | in, |
std::vector< std::vector< int32 > > * | out | ||
) |
Definition at line 367 of file nnet-combined-component.cc.
References rnnlm::i, and rnnlm::j.
Referenced by ConvolutionComponent::InderivPatchesToInderiv(), and MaxpoolingComponent::InderivPatchesToInderiv().
void RecomputeStats | ( | const std::vector< NnetChainExample > & | egs, |
const chain::ChainTrainingOptions & | chain_config, | ||
const fst::StdVectorFst & | den_fst, | ||
Nnet * | nnet | ||
) |
This function zeros the stored component-level stats in the nnet using ZeroComponentStats(), then recomputes them with the supplied egs.
It affects batch-norm, for instance. See also the version of RecomputeStats declared in nnet-utils.h.
Definition at line 248 of file nnet-chain-diagnostics.cc.
References NnetChainComputeProb::Compute(), HasXentOutputs(), rnnlm::i, KALDI_LOG, NnetChainComputeProb::PrintTotalStats(), NnetComputeProbOptions::store_component_stats, and ZeroComponentStats().
Referenced by main().
void RecomputeStats | ( | const std::vector< NnetExample > & | egs, |
Nnet * | nnet | ||
) |
This function zeros the stored component-level stats in the nnet using ZeroComponentStats(), then recomputes them with the supplied egs.
It affects batch-norm, for instance. See also the version of RecomputeStats declared in nnet-chain-diagnostics.h.
Definition at line 550 of file nnet-utils.cc.
References NnetComputeProb::Compute(), rnnlm::i, KALDI_LOG, NnetComputeProb::PrintTotalStats(), NnetComputeProbOptions::store_component_stats, and ZeroComponentStats().
void kaldi::nnet3::ReduceRankOfComponents | ( | const std::string | component_name_pattern, |
int32 | rank, | ||
Nnet * | nnet | ||
) |
Definition at line 1172 of file nnet-utils.cc.
References MatrixBase< Real >::AddMatMat(), AffineComponent::BiasParams(), SvdApplier::ModifiedComponentInfo::component_name, Nnet::GetComponent(), Nnet::GetComponentName(), AffineComponent::InputDim(), KALDI_LOG, KALDI_WARN, kaldi::kCopyData, kaldi::kNoTrans, AffineComponent::LinearParams(), NameMatchesPattern(), Nnet::NumComponents(), AffineComponent::OutputDim(), Matrix< Real >::Resize(), AffineComponent::SetParams(), kaldi::SortSvd(), CuVector< Real >::Swap(), and CuMatrix< Real >::Swap().
Referenced by ReadEditConfig().
void RemoveCommandsForUnusedMatrix | ( | const Analyzer & | analyzer, |
int32 | m, | ||
NnetComputation * | computation | ||
) |
This function removes from 'computation' the commands accessing matrix 'm', which is assumed to be unused according to the MatrixIsUnused() command above.
Specifically, it changes the types of the relevant commands in 'computation' to kNoOperation. (The commands changed in this way will be of type kAllocMatrix, kDeallocMatrix and kSetConst). The index for the matrix may later be removed entirely by RenumberComputation().
Definition at line 4600 of file nnet-optimize-utils.cc.
References MatrixAccesses::accesses, MatrixAccesses::allocate_command, NnetComputation::Command::command_type, NnetComputation::commands, MatrixAccesses::deallocate_command, rnnlm::i, KALDI_ASSERT, kAllocMatrix, kDeallocMatrix, kNoOperation, kSetConst, and Analyzer::matrix_accesses.
Referenced by DerivativeTimeLimiter::PruneMatrices().
void RemoveNoOps | ( | NnetComputation * | computation | ) |
Removes commands of type kNoOperation in the computation.
Definition at line 703 of file nnet-optimize-utils.cc.
References NnetComputation::commands, and IsNoop().
Referenced by DerivativeTimeLimiter::LimitDerivTimes(), VariableMergingOptimizer::MergeVariables(), and RemoveUnnecessaryAllocation().
void RemoveUnnecessaryAllocation | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This optimization detects cases where we deallocate a matrix, and then later allocate another matrix of the same size; and replaces them with commands of type kAllocFromOther or kAllocFromOtherZeroed.
Definition at line 355 of file nnet-optimize.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::command_type, NnetComputation::commands, ComputeCommandPairs(), FixGotoLabel(), rnnlm::i, KALDI_ASSERT, kAllocMatrix, kDeallocMatrix, kaldi::kDefaultStride, kNoOperation, kSwapMatrix, NnetComputation::matrices, RemoveNoOps(), and NnetComputation::submatrices.
Referenced by Optimize().
void RemoveUnnecessaryZeroing | ( | const Nnet & | nnet, |
NnetComputation * | computation | ||
) |
This optimization function removes, where possible, commands of type type kSetConst.
(It can remove them where subsequent commands are going to set the matrix without reading its previous value).
Definition at line 262 of file nnet-optimize.cc.
References MatrixAccesses::accesses, NnetComputation::Command::alpha, ComputationVariables::AppendVariablesForMatrix(), NnetComputation::Command::command_type, NnetComputation::commands, rnnlm::i, Analyzer::Init(), MatrixAccesses::is_output, kNoOperation, kSetConst, kWriteAccess, Analyzer::matrix_accesses, Analyzer::variable_accesses, and Analyzer::variables.
Referenced by Optimize().
void kaldi::nnet3::RenameOutputs | ( | const std::string & | new_name, |
NnetExample * | eg | ||
) |
Definition at line 31 of file nnet3-copy-egs.cc.
References NnetExample::io, and KALDI_ERR.
Referenced by main().
void RenumberComputation | ( | NnetComputation * | computation | ) |
This function detects submatrices and matrices that are never used (e.g.
due to changes made in other optimization code), and members of indexes, indexes_multi and indexes_ranges that are unused or are duplicates, and memo indexes that are unused; and it removes them from the computation by way of suitable renumbering. It does not remove no-ops from computation->commands_; to do that, call RemoveNoOps(computation).
Definition at line 693 of file nnet-optimize-utils.cc.
References ComputationRenumberer::Renumber().
Referenced by MatrixExtender::FixComputation(), DerivativeTimeLimiter::LimitDerivTimes(), VariableMergingOptimizer::MergeVariables(), Optimize(), and ComputationLoopedOptimizer::Optimize().
bool ReplaceRowWithMatrixOps | ( | NnetComputation * | computation | ) |
This function detects cases where commands of type kCopyRows, kAddRows or kAddToRows can be converted to commands of type kMatrixCopy or kMatrixAdd, and converts them (this may involve adding submatrices).
This function returns true if it made any changes to the computation; if it returns true, then after doing this you should at some point do RenumberComputation(), which will remove any now-unused members of computation->indexes.
Definition at line 2288 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::command_type, NnetComputation::commands, NnetComputation::indexes, IndexesHaveSpecialStructure(), kAddRows, KALDI_ASSERT, kCopyRows, kMatrixAdd, kMatrixCopy, and NnetComputation::NewSubMatrix().
Referenced by Optimize().
bool RequestIsDecomposable | ( | const ComputationRequest & | request, |
ComputationRequest * | mini_request, | ||
int32 * | num_n_values | ||
) |
This function, used in 'shortcut' compilation where we first compile a smaller computation with the same structure but only 2 distinct 'n' values, works out whether a computation is 'decomposable'; if so, it returns true and outputs the 'mini_request' with the same structure, and the number of 'n' values.
A computation is decomposable if the following conditions hold:
Definition at line 3852 of file nnet-optimize-utils.cc.
References rnnlm::i, ComputationRequest::inputs, IoSpecificationIsDecomposable(), KALDI_ASSERT, ComputationRequest::misc_info, ComputationRequest::need_model_derivative, ComputationRequest::outputs, and ComputationRequest::store_component_stats.
Referenced by CachingOptimizingCompiler::CompileViaShortcut().
void ResetGenerators | ( | Nnet * | nnet | ) |
This function calls 'ResetGenerator()' on all components in 'nnet' that inherit from class RandomComponent.
It's used when you need to ensure consistency in things like dropout masks, across subsequent neural net evaluations. You will likely want to call srand() before calling this.
Definition at line 582 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and RandomComponent::ResetGenerator().
Referenced by Nnet::Copy(), NnetChainTrainer::Train(), NnetTrainer::Train(), and UnitTestNnetOptimizeWithOptions().
Definition at line 27 of file nnet-component-test.cc.
References RandomComponent::ResetGenerator().
Referenced by TestSimpleComponentDataDerivative(), and TestSimpleComponentPropagateProperties().
void kaldi::nnet3::RoundUpNumFrames | ( | int32 | frame_subsampling_factor, |
int32 * | num_frames, | ||
int32 * | num_frames_overlap | ||
) |
|
static |
Definition at line 33 of file nnet3-xvector-compute.cc.
References NnetComputer::AcceptInput(), CachingOptimizingCompiler::Compile(), VectorBase< Real >::CopyFromVec(), NnetComputer::GetOutputDestructive(), IoSpecification::has_deriv, IoSpecification::indexes, ComputationRequest::inputs, IoSpecification::name, ComputationRequest::need_model_derivative, CuMatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), ComputationRequest::outputs, Vector< Real >::Resize(), CuMatrixBase< Real >::Row(), NnetComputer::Run(), and ComputationRequest::store_component_stats.
Referenced by main().
This function scales the batchorm stats of any batchnorm components (components of type BatchNormComponent) in 'nnet' by the scale 'batchnorm_stats_scale'.
Definition at line 536 of file nnet-utils.cc.
References Nnet::GetComponent(), KALDI_ASSERT, Nnet::NumComponents(), and BatchNormComponent::Scale().
Referenced by CollapseModelConfig::CollapseModelConfig(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), and NnetTrainer::TrainInternalBackstitch().
Scales the nnet parameters and stats by this scale.
Definition at line 312 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and Component::Scale().
Referenced by main(), NnetChainComputeProb::NnetChainComputeProb(), NnetChainTrainer::NnetChainTrainer(), NnetComputeProb::NnetComputeProb(), NnetDiscriminativeComputeObjf::NnetDiscriminativeComputeObjf(), NnetDiscriminativeTrainer::NnetDiscriminativeTrainer(), NnetTrainer::NnetTrainer(), kaldi::ReadModels(), NnetDiscriminativeComputeObjf::Reset(), NnetChainComputeProb::Reset(), NnetComputeProb::Reset(), NnetDiscriminativeTrainer::Train(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), NnetTrainer::TrainInternalBackstitch(), UnitTestNnetModelDerivatives(), UnitTestNnetOptimizeWithOptions(), and UpdateNnetMovingAverage().
void kaldi::nnet3::ScaleSupervisionWeight | ( | BaseFloat | weight, |
NnetExample * | eg | ||
) |
Definition at line 47 of file nnet3-copy-egs.cc.
References NnetExample::io, and KALDI_ERR.
Referenced by main().
bool kaldi::nnet3::SelectFromExample | ( | const NnetExample & | eg, |
std::string | frame_str, | ||
int32 | left_context, | ||
int32 | right_context, | ||
int32 | frame_shift, | ||
NnetExample * | eg_out | ||
) |
This function is responsible for possibly selecting one frame from multiple supervised frames, and reducing the left and right context as specified.
If frame == "" it does not reduce the supervised frames; if frame == "random" it selects one random frame; otherwise it expects frame to be an integer, and will select only the output with that frame index (or return false if there was no such output).
If left_context != -1 it removes any inputs with t < (smallest output - left_context). If left_context != -1 it removes any inputs with t < (smallest output - left_context).
It returns true if it was able to select a frame. We only anticipate it ever returning false in situations where frame is an integer, and the eg came from the end of a file and has a smaller than normal number of supervised frames.
Definition at line 222 of file nnet3-copy-egs.cc.
References ContainsSingleExample(), kaldi::ConvertStringToInteger(), FilterExample(), KALDI_ERR, KALDI_WARN, kaldi::RandInt(), and ShiftExampleTimes().
Referenced by main().
void kaldi::nnet3::SeparateSubmatsWithLargeCounts | ( | const std::vector< int32 > & | submats_to_separate, |
const std::vector< std::vector< std::pair< int32, int32 > > > & | submat_lists, | ||
std::vector< std::vector< std::pair< int32, int32 > > > * | reduced_submat_lists, | ||
std::vector< std::vector< std::pair< int32, int32 > > > * | split_lists | ||
) |
This function, used in SplitLocations(), is used to make separate 'split lists' for certain high-count submatrix indexes, specified by the user in 'submats_to_separate'.
These split lists will be lists of pairs that are all either (-1, 1) or (submatrix_index, x) for a particular submatrix index (constant within the split list). These high-count lists will be written to 'split_lists'; they will eventually compile to AddRows() commands. We write the remaining members of the lists in 'submat_lists' (the ones that did not make it into 'split_lists') to 'reduced_submat_lists'.
Definition at line 73 of file nnet-compile-utils.cc.
References rnnlm::i, and KALDI_ASSERT.
Referenced by SplitLocations().
This function affects only components of type BatchNormComponent.
It sets "test mode" on such components (if you call it with test_mode = true, otherwise it would set normal mode, but this wouldn't be needed often). "test mode" means that instead of using statistics from the batch, it does a deterministic normalization based on statistics stored at training time.
Definition at line 564 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and BatchNormComponent::SetTestMode().
Referenced by ComputeObjf(), main(), TestNnetDecodable(), and UnitTestNnetCompute().
void kaldi::nnet3::SetDerivTimesOptions | ( | const ComputationRequest & | request, |
NnetOptimizeOptions * | opt_config | ||
) |
Definition at line 46 of file nnet-derivative-test.cc.
References ComputeMinAndMaxTimes(), ComputationRequest::inputs, KALDI_ASSERT, KALDI_LOG, NnetOptimizeOptions::max_deriv_time, NnetOptimizeOptions::min_deriv_time, ComputationRequest::outputs, and kaldi::RandInt().
Referenced by UnitTestNnetModelDerivatives().
This function sets the dropout proportion in all dropout components to dropout_proportion value.
Definition at line 509 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), DropoutComponent::SetDropoutProportion(), DropoutMaskComponent::SetDropoutProportion(), and GeneralDropoutComponent::SetDropoutProportion().
This function affects components of child-classes of RandomComponent.
It sets "test mode" on such components (if you call it with test_mode = true, otherwise it would set normal mode, but this wouldn't be needed often). "test mode" means that having a mask containing (1-dropout_prob) in all elements.
Definition at line 573 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and RandomComponent::SetTestMode().
Referenced by ComputeObjf(), main(), TestNnetDecodable(), and UnitTestNnetCompute().
Sets the underlying learning rate for all the components in the nnet to this value.
this will get multiplied by the individual learning-rate-factors to produce the actual learning rates.
Definition at line 276 of file nnet-utils.cc.
References Nnet::GetComponent(), KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), Component::Properties(), and UpdatableComponent::SetUnderlyingLearningRate().
Referenced by main().
void SetNnetAsGradient | ( | Nnet * | nnet | ) |
Sets nnet as gradient by Setting is_gradient_ to true and learning_rate_ to 1 for each UpdatableComponent in nnet.
Definition at line 292 of file nnet-utils.cc.
References Nnet::GetComponent(), KALDI_ASSERT, kUpdatableComponent, Nnet::NumComponents(), Component::Properties(), and UpdatableComponent::SetAsGradient().
Referenced by NnetChainComputeProb::NnetChainComputeProb(), NnetComputeProb::NnetComputeProb(), NnetDiscriminativeComputeObjf::NnetDiscriminativeComputeObjf(), NnetDiscriminativeComputeObjf::Reset(), NnetChainComputeProb::Reset(), NnetComputeProb::Reset(), UnitTestNnetModelDerivatives(), and UnitTestNnetOptimizeWithOptions().
void kaldi::nnet3::SetPriors | ( | const TransitionModel & | tmodel, |
const Vector< double > & | transition_accs, | ||
double | prior_floor, | ||
AmNnetSimple * | am_nnet | ||
) |
Definition at line 28 of file nnet3-am-train-transitions.cc.
References VectorBase< Real >::Dim(), KALDI_ASSERT, AmNnetSimple::NumPdfs(), TransitionModel::NumPdfs(), AmNnetSimple::SetPriors(), and TransitionModel::TransitionIdToPdf().
Referenced by main().
Calls the corresponding function in any component of type StatisticsPoolingComponent; used as a way to compute the 'real' left-right context of networks including SatisticsPoolingComponent, which will give you the minimum chunk size they can consume.
Definition at line 303 of file nnet-utils.cc.
References Nnet::GetComponent(), and Nnet::NumComponents().
Referenced by main().
void ShiftChainExampleTimes | ( | int32 | frame_shift, |
const std::vector< std::string > & | exclude_names, | ||
NnetChainExample * | eg | ||
) |
Shifts the time-index t of everything in the input of "eg" by adding "t_offset" to all "t" values– but excluding those with names listed in "exclude_names", e.g.
"ivector". This might be useful if you are doing subsampling of frames at the output, because shifted examples won't be quite equivalent to their non-shifted counterparts. "exclude_names" is a vector of names of nnet inputs that we avoid shifting the "t" values of– normally it will contain just the single string "ivector" because we always leave t=0 for any ivector.
Note: input features will be shifted by 'frame_shift', and indexes in the supervision in (eg->output) will be shifted by 'frame_shift' rounded to the closest multiple of the frame subsampling factor (e.g. 3). The frame subsampling factor is worked out from the time spacing between the indexes in the output.
Definition at line 353 of file nnet-chain-example.cc.
References NnetChainExample::inputs, KALDI_ASSERT, and NnetChainExample::outputs.
Referenced by NnetChainExampleStructureCompare::operator()().
void ShiftDiscriminativeExampleTimes | ( | int32 | frame_shift, |
const std::vector< std::string > & | exclude_names, | ||
NnetDiscriminativeExample * | eg | ||
) |
Shifts the time-index t of everything in the input of "eg" by adding "t_offset" to all "t" values– but excluding those with names listed in "exclude_names", e.g.
"ivector". This might be useful if you are doing subsampling of frames at the output, because shifted examples won't be quite equivalent to their non-shifted counterparts. "exclude_names" is a vector of names of nnet inputs that we avoid shifting the "t" values of– normally it will contain just the single string "ivector" because we always leave t=0 for any ivector.
Note: input features will be shifted by 'frame_shift', and indexes in the supervision in (eg->output) will be shifted by 'frame_shift' rounded to the closest multiple of the frame subsampling factor (e.g. 3). The frame subsampling factor is worked out from the time spacing between the indexes in the output.
Definition at line 347 of file nnet-discriminative-example.cc.
References NnetDiscriminativeExample::inputs, KALDI_ASSERT, and NnetDiscriminativeExample::outputs.
Referenced by main(), and NnetDiscriminativeExampleStructureCompare::operator()().
void ShiftExampleTimes | ( | int32 | t_offset, |
const std::vector< std::string > & | exclude_names, | ||
NnetExample * | eg | ||
) |
Shifts the time-index t of everything in the "eg" by adding "t_offset" to all "t" values.
This might be useful in things like clockwork RNNs that are not invariant to time-shifts, to ensure that we see different shifts of each example during training. "exclude_names" is a vector (not necessarily sorted) of names of nnet inputs that we avoid shifting the "t" values of– normally it will contain just the single string "ivector" because we always leave t=0 for any ivector.
Definition at line 174 of file nnet-example-utils.cc.
References NnetExample::io.
Referenced by SelectFromExample().
|
static |
Definition at line 2434 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::commands, FindNumLeadingAndTrailingNegatives(), NnetComputation::indexes_multi, KALDI_ASSERT, and NnetComputation::NewSubMatrix().
Referenced by SnipRowOps().
|
static |
Definition at line 2507 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg3, NnetComputation::commands, FindNumLeadingAndTrailingIdenticals(), NnetComputation::indexes_ranges, KALDI_ASSERT, and NnetComputation::NewSubMatrix().
Referenced by SnipRowOps().
bool SnipRowOps | ( | NnetComputation * | computation | ) |
This function detects cases where commands of type kCopyRows, kAddRows, kAddRowsMulti, kAddToRowsMulti, kCopyRowsMulti, kCopyToRowsMulti or kAddRowRanges use indexes that start or end with -1's or equivalents, and replace them with similar commands that act on a sub-matrix of the matrices they are currently acting on.
This will help efficiency by avoiding launching unnecessary copies of the kernel (that don't really have to do anything).
This function returns true if it made any changes to the computation; if it returns true, then after doing this you should at some point do RenumberComputation(), which will remove any now-unused members of computation->indexes.
Definition at line 2537 of file nnet-optimize-utils.cc.
References NnetComputation::Command::command_type, NnetComputation::commands, kAddRowRanges, kAddRows, kAddRowsMulti, kAddToRowsMulti, kCopyToRowsMulti, SnipMultiRowOp(), SnipRangesRowOp(), and SnipSingleRowOp().
Referenced by Optimize().
|
static |
Definition at line 2364 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg3, NnetComputation::commands, FindNumLeadingAndTrailingNegatives(), NnetComputation::indexes, KALDI_ASSERT, and NnetComputation::NewSubMatrix().
Referenced by SnipRowOps().
|
static |
Split the computation up into segments bounded by kNoOperationMarker.
For each segment, a pair of command-indexes (start, end) is output to the vector 'segments', so the commands in the segment (not including kNoOperationMarker) are numbered from start ... end - 1.
Definition at line 852 of file nnet-optimize.cc.
References NnetComputation::commands, and kNoOperationMarker.
Referenced by ConsolidateIoOperations().
void SplitLocations | ( | const std::vector< std::vector< std::pair< int32, int32 > > > & | submat_lists, |
std::vector< std::vector< std::pair< int32, int32 > > > * | split_lists | ||
) |
The input to this function is a vector (indexed by matrix-row-index) of lists of pairs (submat_index, row_index), and this function splits it up into a list of vectors of pairs, where those vectors are indexed by matrix-row-index.
In order to make the lists all the same length it may have to insert "dummy" pairs with value (-1, -1). In addition, this function implement certain heuristics to break up the list into pairs in a particular desirable way, which we will describe below.
Let the input be `submat_lists`, and let `num_rows = submat_lists.size()`. The value -1 is not expected to appear as either the .first or .second element of pairs in `submat_lists`.
Heuristics aside, what this function guarantees is as follows. Each pair p that is in an element of list `submat_lists[i]` (say `p = submat_lists[i][k]`), will be present as `(*split_lists)[j][i] == p`. Because we don't ban submat_lists[i] from containing duplicates, the technical definition is a little more complicated: that the count of any given pair p != (-1, -1) in `submat_lists[i][*]` is equal to the count of that same pair in `(*split_lists)[*][i]`.
Each pair present in split_lists is either (-1, -1), or will correspond to an element of submat_lists; thus the total number of pairs, excluding (-1, -1), in split_lists will be the same as the total number of pairs in submat_lists.
Note on expected input: submat_lists.dim() may be large e.g. 1024 (it usually represents a minibatch size), but the maximum size of the lists will usually be fairly small e.g. no more than 4 or so, as it represents the number of terms in a hand-coded summation expression.
The use of this function is in interpreting a command to set each row of a matrix to a sum of terms. Each pair represents an input term, interpreted as (index-of-matrix, row-index), which represents a vector that will form part of the sum.
It would be possible to simply pad at the end with (-1, -1), but this function also makes an attempt to pad more carefully so that for the most part, each output vector of pairs has inputs from only one matrix, i.e. the pair.first values are all the same. This will allow us to use a potentially more efficient command in the compiled code. It doesn't have to be 100% optimal. Note: in the most common case, all the lists will have the same length and padding will not be necessary at all.
See documentation here: Forward computation for Descriptors (SplitLocations)
Definition at line 120 of file nnet-compile-utils.cc.
References GetSubmatCounts(), rnnlm::i, and SeparateSubmatsWithLargeCounts().
Referenced by Compiler::CompileForwardFromSubmatLocationsList(), SplitLocationsBackward(), and UnitTestSplitLocations().
void SplitLocationsBackward | ( | const std::vector< std::vector< std::pair< int32, int32 > > > & | submat_lists, |
std::vector< std::vector< std::pair< int32, int32 > > > * | split_lists | ||
) |
This function has the same interface as SplitLocations(); however, it ensures certain additional properties of the output "split_lists", which are necessary because of the way it is used in backprop code.
For each sub-list sublist = (*split_lists)[i], the properties it ensures are: Either:
Definition at line 311 of file nnet-compile-utils.cc.
References ConvertToIndexes(), EnsureContiguousProperty(), rnnlm::i, rnnlm::j, SplitLocations(), and SplitPairList().
Referenced by Compiler::CompileBackwardFromSubmatLocationsList(), and UnitTestSplitLocationsBackward().
void kaldi::nnet3::SplitPairList | ( | std::vector< std::pair< int32, int32 > > & | list, |
std::vector< std::vector< std::pair< int32, int32 > > > * | split_lists | ||
) |
This function splits a vector of pairs into a list of vectors of pairs.
[note: by 'vector' we mean something that has a meaningful index that we care about; by 'list' we mean a collection of elements to be iterated over, without (in this case) meaningful indexes or even order.
[in] | list | A vector of pairs; these pairs should be either (-1,-1) or (a,b) for a >= 0, b >= 0. At least one element of 'list' must be different from (-1,-1). |
[out] | split_lists | A list, in arbitrary order, of vectors of pairs. It has the following relationship with 'list':
|
Definition at line 280 of file nnet-compile-utils.cc.
References rnnlm::i, KALDI_ASSERT, and KALDI_ERR.
Referenced by SplitLocationsBackward().
bool SplitRowOps | ( | NnetComputation * | computation | ) |
This function detects cases where commands of type kAddRowsMulti, kAddToRowsMulti, kCopyRowsMulti, kCopyToRowsMulti use indexes that correspond to at most two submatrices, in two distinct ranges without gaps filled by -1's, and could be converted to at most two commands of type kMatrixAdd, kMatrixCopy, kAddRows or kCopyRows.
(Note: it's important that this optimization takes place after SnipRowOps, because it doesn't remove the -1's from the edges of the indexes, it relies on that operation doing so). The "without-gaps" stipulation is just for convenience of implementation, to have fewer cases to worry about.
This function returns true if it made any changes to the computation; if it returns true, then after calling this you should at some point do RenumberComputation(), which will remove any now-unused members of computation->indexes.
Definition at line 2894 of file nnet-optimize-utils.cc.
References RowOpsSplitter::Split().
Referenced by Optimize().
std::string SummarizeVector | ( | const VectorBase< float > & | vec | ) |
Returns a string that summarizes a vector fairly succintly, for printing stats in info lines.
For example: "[percentiles(0,1,2,5 10,20,50,80,90 95,98,99,100)=(0.001,0.003,0.003,0.004 \ 0.005,0.01,0.07,0.11,0.14 0.18,0.24,0.29,0.39), mean=0.0745, stddev=0.0611]"
Definition at line 111 of file nnet-parse.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, rnnlm::n, PrintFloatSuccinctly(), kaldi::SplitStringToIntegers(), VectorBase< Real >::Sum(), and kaldi::VecVec().
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), BatchNormComponent::Info(), LstmNonlinearityComponent::Info(), NonlinearComponent::Info(), PrintParameterStats(), SummarizeVector(), and UnitTestSummarizeVector().
std::string SummarizeVector | ( | const VectorBase< double > & | vec | ) |
Definition at line 147 of file nnet-parse.cc.
References SummarizeVector().
std::string SummarizeVector | ( | const CuVectorBase< BaseFloat > & | cu_vec | ) |
Definition at line 152 of file nnet-parse.cc.
References SummarizeVector().
Definition at line 1238 of file nnet-computation-graph.cc.
Referenced by ComputeComputationPhases(), and SumVectorSizes().
|
static |
Definition at line 1247 of file nnet-computation-graph.cc.
References rnnlm::i, and SumVectorSizes().
void kaldi::nnet3::TarjanSccRecursive | ( | int32 | node, |
const std::vector< std::vector< int32 > > & | graph, | ||
int32 * | global_index, | ||
std::vector< TarjanNode > * | tarjan_nodes, | ||
std::vector< int32 > * | tarjan_stack, | ||
std::vector< std::vector< int32 > > * | sccs | ||
) |
Definition at line 85 of file nnet-graph.cc.
References rnnlm::i, TarjanNode::index, KALDI_ASSERT, TarjanNode::lowlink, and TarjanNode::on_stack.
Referenced by FindSccsTarjan().
void kaldi::nnet3::TestNnetComponentAddScale | ( | Component * | c | ) |
Definition at line 76 of file nnet-component-test.cc.
References Component::Add(), CheckStringsApproxEqual(), Component::Copy(), Component::Info(), KALDI_ASSERT, and Component::Scale().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestNnetComponentCopy | ( | Component * | c | ) |
Definition at line 67 of file nnet-component-test.cc.
References Component::Copy(), Component::Info(), KALDI_ERR, and kaldi::StringsApproxEqual().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestNnetComponentIo | ( | Component * | c | ) |
Definition at line 52 of file nnet-component-test.cc.
References CheckStringsApproxEqual(), KALDI_ASSERT, kaldi::Rand(), Component::ReadNew(), and Component::Write().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestNnetComponentUpdatable | ( | Component * | c | ) |
Definition at line 109 of file nnet-component-test.cc.
References CheckStringsApproxEqual(), Component::Copy(), UpdatableComponent::DotProduct(), UpdatableComponent::Info(), KALDI_ASSERT, KALDI_ERR, kUpdatableComponent, UpdatableComponent::NumParameters(), Component::Properties(), VectorBase< Real >::Scale(), Component::Scale(), kaldi::StringsApproxEqual(), and kaldi::VecVec().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestNnetComponentVectorizeUnVectorize | ( | Component * | c | ) |
Definition at line 86 of file nnet-component-test.cc.
References kaldi::ApproxEqual(), CheckStringsApproxEqual(), Component::Copy(), UpdatableComponent::DotProduct(), rnnlm::i, UpdatableComponent::Info(), KALDI_ASSERT, kUpdatableComponent, UpdatableComponent::NumParameters(), Component::Properties(), Component::Scale(), UpdatableComponent::UnVectorize(), and UpdatableComponent::Vectorize().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestNnetDecodable | ( | Nnet * | nnet | ) |
Definition at line 80 of file nnet-compute-test.cc.
References VectorBase< Real >::ApplyExp(), VectorBase< Real >::Dim(), NnetSimpleComputationOptions::frames_per_chunk, DecodableNnetSimple::GetOutputForFrame(), DecodableNnetSimpleLooped::GetOutputForFrame(), Nnet::Info(), Nnet::InputDim(), KALDI_ASSERT, NnetIsRecurrent(), Nnet::OutputDim(), kaldi::RandInt(), SetBatchnormTestMode(), SetDropoutTestMode(), and VectorBase< Real >::SetRandn().
Referenced by UnitTestNnetCompute().
bool kaldi::nnet3::TestSimpleComponentDataDerivative | ( | const Component & | c, |
BaseFloat | perturb_delta | ||
) |
Definition at line 309 of file nnet-component-test.cc.
References kaldi::ApproxEqual(), Component::Backprop(), Component::DeleteMemo(), GetPrecomputedIndexes(), rnnlm::i, Component::InputDim(), KALDI_LOG, KALDI_WARN, kBackpropNeedsInput, kBackpropNeedsOutput, kaldi::kDefaultStride, kInputContiguous, kOutputContiguous, kaldi::kSetZero, kaldi::kStrideEqualNumCols, kaldi::kTrans, Component::OutputDim(), Component::Propagate(), Component::Properties(), kaldi::Rand(), kaldi::RandInt(), ResetSeed(), CuMatrixBase< Real >::SetRandn(), kaldi::TraceMatMat(), and Component::Type().
Referenced by UnitTestNnetComponent().
bool kaldi::nnet3::TestSimpleComponentModelDerivative | ( | const Component & | c, |
BaseFloat | perturb_delta, | ||
bool | test_derivative | ||
) |
Definition at line 390 of file nnet-component-test.cc.
References kaldi::ApproxEqual(), Component::Backprop(), Component::Copy(), Component::DeleteMemo(), UpdatableComponent::DotProduct(), GetPrecomputedIndexes(), rnnlm::i, Component::InputDim(), KALDI_ASSERT, KALDI_LOG, KALDI_WARN, kBackpropNeedsInput, kBackpropNeedsOutput, kaldi::kDefaultStride, kInputContiguous, kOutputContiguous, kaldi::kSetZero, kaldi::kStrideEqualNumCols, kaldi::kTrans, kUpdatableComponent, Component::OutputDim(), UpdatableComponent::PerturbParams(), Component::Propagate(), Component::Properties(), kaldi::RandInt(), Component::Scale(), UpdatableComponent::SetAsGradient(), CuMatrixBase< Real >::SetRandn(), kaldi::TraceMatMat(), and Component::Type().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::TestSimpleComponentPropagateProperties | ( | const Component & | c | ) |
Definition at line 210 of file nnet-component-test.cc.
References CuMatrixBase< Real >::Add(), kaldi::AssertEqual(), Component::Backprop(), Component::Copy(), CuMatrixBase< Real >::CopyFromMat(), Component::DeleteMemo(), GetPrecomputedIndexes(), Component::InputDim(), KALDI_ERR, kBackpropAdds, kBackpropInPlace, kBackpropNeedsInput, kBackpropNeedsOutput, kaldi::kDefaultStride, kInputContiguous, kOutputContiguous, kPropagateAdds, kPropagateInPlace, kaldi::kSetZero, kaldi::kStrideEqualNumCols, kaldi::kUndefined, Component::OutputDim(), Component::Propagate(), Component::Properties(), kaldi::Rand(), kaldi::RandInt(), ResetSeed(), CuMatrixBase< Real >::SetRandn(), and Component::Type().
Referenced by UnitTestNnetComponent().
void kaldi::nnet3::UnitTestCindexIo | ( | ) |
Definition at line 62 of file nnet-common-test.cc.
References rnnlm::i, KALDI_ERR, Index::n, kaldi::RandInt(), ReadCindexVector(), Index::t, WriteCindexVector(), and Index::x.
Referenced by main().
void kaldi::nnet3::UnitTestComputationRequestIo | ( | ComputationRequest * | request | ) |
Definition at line 56 of file nnet-compute-test.cc.
References KALDI_ASSERT, kaldi::Rand(), ComputationRequest::Read(), and ComputationRequest::Write().
Referenced by UnitTestNnetCompute().
void kaldi::nnet3::UnitTestComputeGraphTranspose | ( | ) |
Definition at line 148 of file nnet-graph-test.cc.
References AssertGraphEqual(), BuildTestGraph(), BuildTestGraphTranspose(), ComputeGraphTranspose(), and KALDI_ASSERT.
Referenced by main().
void kaldi::nnet3::UnitTestComputeTopSortOrder | ( | ) |
Definition at line 187 of file nnet-graph-test.cc.
References AssertVectorEqual(), BuildTestSccGraph(), BuildTestTopSortOrder(), ComputeTopSortOrder(), and KALDI_ASSERT.
Referenced by main().
void kaldi::nnet3::UnitTestComputeTopSortOrder2 | ( | ) |
Definition at line 199 of file nnet-graph-test.cc.
References AssertVectorEqual(), ComputeTopSortOrder(), and KALDI_ASSERT.
Referenced by main().
void kaldi::nnet3::UnitTestConvertRepeatedToBlockAffine | ( | ) |
Definition at line 50 of file nnet-utils-test.cc.
References ConvertRepeatedToBlockAffine(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, Nnet::NumComponents(), Nnet::ReadConfig(), and Component::Type().
Referenced by main().
void kaldi::nnet3::UnitTestConvertRepeatedToBlockAffineComposite | ( | ) |
Definition at line 82 of file nnet-utils-test.cc.
References ConvertRepeatedToBlockAffine(), GenerateConfigSequenceCompositeBlock(), Nnet::GetComponent(), CompositeComponent::GetComponent(), rnnlm::i, KALDI_ASSERT, Nnet::NumComponents(), CompositeComponent::NumComponents(), NnetGenerationOptions::output_dim, Nnet::ReadConfig(), and Component::Type().
Referenced by main().
void kaldi::nnet3::UnitTestDescriptorIo | ( | ) |
Definition at line 89 of file nnet-descriptor-test.cc.
References DescriptorTokenize(), GenRandDescriptor(), rnnlm::i, KALDI_ASSERT, KALDI_LOG, KALDI_WARN, Descriptor::Parse(), kaldi::Rand(), and Descriptor::WriteConfig().
Referenced by main().
void kaldi::nnet3::UnitTestDescriptorTokenize | ( | ) |
Definition at line 27 of file nnet-parse-test.cc.
References DescriptorTokenize(), and KALDI_ASSERT.
Referenced by main().
void kaldi::nnet3::UnitTestEnsureContiguousProperty | ( | ) |
Definition at line 222 of file nnet-compile-utils-test.cc.
References EnsureContiguousProperty(), HasContiguousProperty(), rnnlm::i, rnnlm::j, KALDI_ASSERT, and kaldi::RandInt().
Referenced by main().
void kaldi::nnet3::UnitTestFindSccs | ( | ) |
Definition at line 160 of file nnet-graph-test.cc.
References AssertGraphEqual(), BuildTestGraph(), BuildTestSccs(), FindSccs(), and KALDI_ASSERT.
Referenced by main().
void kaldi::nnet3::UnitTestGeneralDescriptor | ( | ) |
Definition at line 135 of file nnet-descriptor-test.cc.
References GeneralDescriptor::ConvertToDescriptor(), DescriptorTokenize(), GenRandDescriptor(), rnnlm::i, KALDI_ERR, KALDI_LOG, KALDI_WARN, GeneralDescriptor::Parse(), kaldi::Rand(), and Descriptor::WriteConfig().
Referenced by main().
void kaldi::nnet3::UnitTestGeneralDescriptorSpecial | ( | ) |
Definition at line 200 of file nnet-descriptor-test.cc.
References KALDI_ASSERT, and NormalizeTextDescriptor().
Referenced by main().
void kaldi::nnet3::UnitTestHasContiguousProperty | ( | ) |
Definition at line 185 of file nnet-compile-utils-test.cc.
References HasContiguousProperty(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_LOG, and kaldi::RandInt().
Referenced by main().
void kaldi::nnet3::UnitTestIndexIo | ( | ) |
Definition at line 28 of file nnet-common-test.cc.
References rnnlm::i, KALDI_ERR, kaldi::RandInt(), ReadIndexVector(), and WriteIndexVector().
Referenced by main().
void kaldi::nnet3::UnitTestMakeSccGraph | ( | ) |
Definition at line 172 of file nnet-graph-test.cc.
References AssertGraphEqual(), BuildTestGraph(), BuildTestSccGraph(), BuildTestSccs(), KALDI_ASSERT, and MakeSccGraph().
Referenced by main().
void kaldi::nnet3::UnitTestNameMatchesPattern | ( | ) |
Definition at line 76 of file nnet-parse-test.cc.
References KALDI_ASSERT, and NameMatchesPattern().
Referenced by main().
void kaldi::nnet3::UnitTestNnetAnalyze | ( | ) |
Definition at line 39 of file nnet-analyze-test.cc.
References ComputationChecker::Check(), CheckComputationOptions::check_rewrite, NnetComputation::commands, ComputeExampleComputationRequestSimple(), Compiler::CreateComputation(), ComputationAnalysis::DataInvalidatedCommand(), ComputationAnalysis::FirstNontrivialAccess(), GenerateConfigSequence(), NnetComputation::GetSubmatrixStrings(), Analyzer::Init(), rnnlm::j, KALDI_LOG, ComputationAnalysis::LastAccess(), ComputationAnalysis::LastWriteAccess(), rnnlm::n, NnetComputation::Print(), PrintCommand(), kaldi::RandInt(), Nnet::ReadConfig(), and NnetComputation::submatrices.
Referenced by main().
void kaldi::nnet3::UnitTestNnetCompile | ( | ) |
Definition at line 29 of file nnet-compile-test.cc.
References ComputeExampleComputationRequestSimple(), Compiler::CreateComputation(), GenerateConfigSequence(), rnnlm::j, KALDI_LOG, rnnlm::n, ComputationRequest::Print(), NnetComputation::Print(), and Nnet::ReadConfig().
Referenced by main().
void kaldi::nnet3::UnitTestNnetCompileLooped | ( | ) |
Definition at line 120 of file nnet-compile-test.cc.
References NnetGenerationOptions::allow_ivector, CompileLooped(), CreateLoopedComputationRequestSimple(), GenerateConfigSequence(), GetChunkSize(), Nnet::Info(), rnnlm::j, KALDI_LOG, ModifyNnetIvectorPeriod(), rnnlm::n, ComputationRequest::Print(), NnetComputation::Print(), kaldi::RandInt(), and Nnet::ReadConfig().
Referenced by main().
void kaldi::nnet3::UnitTestNnetCompileMulti | ( | ) |
Definition at line 63 of file nnet-compile-test.cc.
References NnetGenerationOptions::allow_use_of_x_dim, ComputeExampleComputationRequestSimple(), GenerateConfigSequence(), rnnlm::i, ComputationRequest::inputs, rnnlm::j, KALDI_LOG, rnnlm::n, ComputationRequest::need_model_derivative, ComputationRequest::outputs, ComputationRequest::Print(), Nnet::ReadConfig(), and ComputationRequest::store_component_stats.
Referenced by main().
void kaldi::nnet3::UnitTestNnetComponent | ( | ) |
Definition at line 490 of file nnet-component-test.cc.
References GenerateRandomSimpleComponent(), Component::Info(), KALDI_ERR, KALDI_LOG, rnnlm::n, TestNnetComponentAddScale(), TestNnetComponentCopy(), TestNnetComponentIo(), TestNnetComponentUpdatable(), TestNnetComponentVectorizeUnVectorize(), TestSimpleComponentDataDerivative(), TestSimpleComponentModelDerivative(), and TestSimpleComponentPropagateProperties().
Referenced by main().
void kaldi::nnet3::UnitTestNnetComputationIo | ( | NnetComputation * | computation | ) |
Definition at line 34 of file nnet-compute-test.cc.
References KALDI_ERR, kaldi::Rand(), NnetComputation::Read(), and NnetComputation::Write().
Referenced by UnitTestNnetCompute().
void kaldi::nnet3::UnitTestNnetCompute | ( | ) |
Definition at line 147 of file nnet-compute-test.cc.
References NnetComputer::AcceptInput(), kaldi::ApproxEqual(), ComputationChecker::Check(), CheckComputationOptions::check_rewrite, CollapseModel(), NnetComputation::ComputeCudaIndexes(), ComputeExampleComputationRequestSimple(), Compiler::CreateComputation(), NnetComputeOptions::debug, GenerateConfigSequence(), NnetComputer::GetOutput(), rnnlm::i, ComputationRequest::inputs, rnnlm::j, KALDI_ERR, KALDI_LOG, MaxOutputTimeInRequest(), rnnlm::n, Optimize(), ComputationRequest::outputs, NnetComputation::Print(), kaldi::RandInt(), Nnet::ReadConfig(), NnetComputer::Run(), SetBatchnormTestMode(), SetDropoutTestMode(), CuMatrixBase< Real >::SetRandn(), CuMatrixBase< Real >::Sum(), TestNnetDecodable(), UnitTestComputationRequestIo(), and UnitTestNnetComputationIo().
Referenced by main().
void kaldi::nnet3::UnitTestNnetContext | ( | ) |
Definition at line 29 of file nnet-utils-test.cc.
References ComputeSimpleNnetContext(), GenerateConfigSequence(), KALDI_LOG, rnnlm::n, NnetInfo(), and Nnet::ReadConfig().
Referenced by main().
void kaldi::nnet3::UnitTestNnetExample | ( | ) |
Definition at line 35 of file nnet-example-test.cc.
References ExampleApproxEqual(), GenerateSimpleNnetTrainingExample(), KALDI_ASSERT, rnnlm::n, kaldi::RandInt(), NnetExample::Read(), and NnetExample::Write().
Referenced by main().
void kaldi::nnet3::UnitTestNnetInputDerivatives | ( | ) |
Definition at line 246 of file nnet-derivative-test.cc.
References NnetComputer::AcceptInput(), CuMatrixBase< Real >::AddMat(), kaldi::ApproxEqual(), ComputationChecker::Check(), CheckComputationOptions::check_rewrite, ComputeExampleComputationRequestSimple(), rnnlm::d, NnetComputeOptions::debug, GenerateConfigSequence(), NnetComputer::GetOutput(), rnnlm::i, ComputationRequest::inputs, rnnlm::j, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, KALDI_WARN, kaldi::kTrans, MaxOutputTimeInRequest(), rnnlm::n, ComputationRequest::need_model_derivative, NnetIsRecurrent(), Optimize(), Nnet::OutputDim(), ComputationRequest::outputs, kaldi::RandInt(), Nnet::ReadConfig(), CuMatrix< Real >::Resize(), NnetComputer::Run(), CuMatrixBase< Real >::SetRandn(), and kaldi::TraceMatMat().
Referenced by main().
void kaldi::nnet3::UnitTestNnetIo | ( | ) |
Definition at line 27 of file nnet-nnet-test.cc.
References GenerateConfigSequence(), KALDI_ASSERT, rnnlm::n, kaldi::Rand(), Nnet::Read(), Nnet::ReadConfig(), and Nnet::Write().
Referenced by main().
void kaldi::nnet3::UnitTestNnetMergeExamples | ( | ) |
Definition at line 67 of file nnet-example-test.cc.
References GenerateSimpleNnetTrainingExample(), rnnlm::i, KALDI_LOG, MergeExamples(), rnnlm::n, kaldi::RandInt(), and NnetExample::Write().
Referenced by main().
void kaldi::nnet3::UnitTestNnetModelDerivatives | ( | ) |
Definition at line 91 of file nnet-derivative-test.cc.
References NnetComputer::AcceptInput(), kaldi::ApproxEqual(), CachingOptimizingCompiler::Compile(), ComputeExampleComputationRequestSimple(), rnnlm::d, NnetComputeOptions::debug, DotProduct(), GenerateConfigSequence(), NnetComputer::GetOutput(), rnnlm::i, ComputationRequest::inputs, rnnlm::j, KALDI_ERR, KALDI_LOG, KALDI_WARN, kaldi::kTrans, rnnlm::n, ComputationRequest::need_model_derivative, NnetIsRecurrent(), Nnet::OutputDim(), ComputationRequest::outputs, PerturbParams(), NnetComputation::Print(), kaldi::RandInt(), Nnet::ReadConfig(), CuMatrix< Real >::Resize(), NnetComputer::Run(), ScaleNnet(), SetDerivTimesOptions(), SetNnetAsGradient(), CuMatrixBase< Real >::SetRandn(), and kaldi::TraceMatMat().
Referenced by main().
|
static |
Definition at line 295 of file nnet-optimize-test.cc.
References KALDI_LOG, and UnitTestNnetOptimizeInternal().
Referenced by main().
|
static |
Definition at line 194 of file nnet-optimize-test.cc.
References NnetOptimizeOptions::allocate_from_other, NnetOptimizeOptions::backprop_in_place, NnetOptimizeOptions::convert_addition, NnetOptimizeOptions::initialize_undefined, KALDI_ERR, KALDI_SUCCFAIL, NnetOptimizeOptions::max_deriv_time, NnetOptimizeOptions::max_deriv_time_relative, NnetOptimizeOptions::min_deriv_time, NnetOptimizeOptions::move_sizing_commands, NnetOptimizeOptions::optimize_row_ops, NnetOptimizeOptions::propagate_in_place, kaldi::RandInt(), NnetOptimizeOptions::remove_assignments, NnetOptimizeOptions::snip_row_ops, UnitTestNnetOptimizeWithOptions(), and CachingOptimizingCompilerOptions::use_shortcut.
Referenced by UnitTestNnetOptimize().
|
static |
Definition at line 33 of file nnet-optimize-test.cc.
References NnetComputer::AcceptInput(), kaldi::ApproxEqual(), ComputationChecker::Check(), CheckComputationOptions::check_rewrite, CachingOptimizingCompiler::Compile(), NnetComputation::ComputeCudaIndexes(), ComputeExampleComputationRequestSimple(), Compiler::CreateComputation(), NnetComputeOptions::debug, GenerateConfigSequence(), NnetComputer::GetOutput(), rnnlm::i, ComputationRequest::inputs, rnnlm::j, KALDI_LOG, KALDI_WARN, NnetParametersAreIdentical(), ComputationRequest::outputs, NnetComputation::Print(), kaldi::RandInt(), Nnet::ReadConfig(), ResetGenerators(), NnetComputer::Run(), ScaleNnet(), SetNnetAsGradient(), CuMatrixBase< Real >::SetRandn(), and CuMatrixBase< Real >::Sum().
Referenced by UnitTestNnetOptimizeInternal().
void kaldi::nnet3::UnitTestPreconditionDirectionsOnline | ( | ) |
Definition at line 262 of file natural-gradient-online-test.cc.
References CuVectorBase< Real >::AddDiagMatMat(), MatrixBase< Real >::AddVecVec(), kaldi::AssertEqual(), KALDI_ASSERT, kaldi::kNoTrans, kaldi::kTrans, CuMatrixBase< Real >::NumRows(), OnlineNaturalGradientSimple::PreconditionDirections(), OnlineNaturalGradient::PreconditionDirections(), kaldi::Rand(), kaldi::RandInt(), VectorBase< Real >::Scale(), MatrixBase< Real >::Set(), VectorBase< Real >::SetRandn(), MatrixBase< Real >::SetRandn(), OnlineNaturalGradientSimple::SetRank(), OnlineNaturalGradient::SetRank(), kaldi::TraceMatMat(), and OnlineNaturalGradient::TurnOnDebug().
Referenced by main().
void kaldi::nnet3::UnitTestSplitLocations | ( | bool | verbose | ) |
Definition at line 275 of file nnet-compile-utils-test.cc.
References ComparePair::ComparePair(), ConvertToIndexes(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_LOG, PrintVectorVectorPair(), kaldi::Rand(), and SplitLocations().
Referenced by main().
void kaldi::nnet3::UnitTestSplitLocationsBackward | ( | bool | verbose | ) |
Definition at line 70 of file nnet-compile-utils-test.cc.
References ComparePair::ComparePair(), ConvertToIndexes(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_LOG, PrintVectorVectorPair(), kaldi::Rand(), and SplitLocationsBackward().
Referenced by main().
void kaldi::nnet3::UnitTestSummarizeVector | ( | ) |
Definition at line 55 of file nnet-parse-test.cc.
References KALDI_LOG, kaldi::kCopyData, Vector< Real >::Resize(), VectorBase< Real >::SetRandn(), and SummarizeVector().
Referenced by main().
void UnVectorizeNnet | ( | const VectorBase< BaseFloat > & | params, |
Nnet * | dest | ||
) |
Copies the parameters from params to *dest.
the dimension of params must be equal to NumParameters(*dest).
Definition at line 401 of file nnet-utils.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), KALDI_ASSERT, KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), NumParameters(), UpdatableComponent::NumParameters(), Component::Properties(), and UpdatableComponent::UnVectorize().
void kaldi::nnet3::UpdateNnetMovingAverage | ( | int32 | num_models, |
const Nnet & | nnet, | ||
Nnet * | moving_average_nnet | ||
) |
Definition at line 66 of file nnet3-combine.cc.
References AddNnet(), KALDI_ASSERT, NumParameters(), and ScaleNnet().
Referenced by main().
bool UpdateNnetWithMaxChange | ( | const Nnet & | delta_nnet, |
BaseFloat | max_param_change, | ||
BaseFloat | max_change_scale, | ||
BaseFloat | scale, | ||
Nnet * | nnet, | ||
std::vector< int32 > * | num_max_change_per_component_applied, | ||
int32 * | num_max_change_global_applied | ||
) |
This function does the operation '*nnet += scale * delta_nnet', while respecting any max-parameter-change (max-param-change) specified in the updatable components, and also the global max-param-change specified as 'max_param_change'.
With max-changes taken into account, the operation of this function is equivalent to the following, although it's done more efficiently:
[in] | delta_nnet | The copy of '*nnet' neural network that contains the proposed change in parameters. Normally this will previously have been set to: (delta_nnet = parameter-derivative-on-current-minibatch * learning-rate per parameter), with any natural gradient applied as specified in the components; but this may be different if momentum or backstitch are used. |
[in] | max_param_change | The global max-param-change specified on the command line (e.g. 2.0), which specifies the largest change allowed to '*nnet' in Euclidean norm. If <= 0, no global max-param-change will be enforced, but any max-change values specified in the components will still be enforced; see UpdatableComponent::MaxChange(), and search for 'max-change' in the configs or nnet3-info output). |
[in] | max_change_scale | This value, which will normally be 1.0, is used to scale all per-component max-change values and the global 'max_param_change', before applying them (so we use 'max_change_scale * uc->MaxChange()' as the per-component max-change, and 'max_change_scale * max_param_change' as the global max-change). |
[in] | scale | This value, which will normally be 1.0, is a scaling factor used when adding to 'nnet', applied after any max-changes. It is provided for backstitch-related purposes. |
[in,out] | nnet | The nnet which we add to. |
[out] | num_max_change_per_component_applied | We add to the elements of this the count for each per-component max-change. |
[out] | num_max_change_global_applied | We to this the count for the global max-change. |
Definition at line 2106 of file nnet-utils.cc.
References AddNnetComponents(), VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), Nnet::GetComponentName(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_LOG, KALDI_VLOG, KALDI_WARN, kUpdatableComponent, UpdatableComponent::MaxChange(), Nnet::NumComponents(), NumUpdatableComponents(), Component::Properties(), and VectorBase< Real >::Scale().
Referenced by CollapseModelConfig::CollapseModelConfig(), NnetChainTrainer::TrainInternal(), NnetTrainer::TrainInternal(), NnetChainTrainer::TrainInternalBackstitch(), NnetTrainer::TrainInternalBackstitch(), and UpdateNnetWithMaxChange().
bool UpdateNnetWithMaxChange | ( | const Nnet & | delta_nnet, |
BaseFloat | max_param_change, | ||
BaseFloat | max_change_scale, | ||
BaseFloat | scale, | ||
Nnet * | nnet, | ||
MaxChangeStats * | stats | ||
) |
Definition at line 2269 of file nnet-utils.cc.
References MaxChangeStats::num_max_change_global_applied, MaxChangeStats::num_max_change_per_component_applied, MaxChangeStats::num_minibatches_processed, and UpdateNnetWithMaxChange().
void VariableMergingOptimization | ( | const NnetOptimizeOptions & | config, |
const Nnet & | nnet, | ||
NnetComputation * | computation | ||
) |
This wraps class VariableMergingOptimizer in a simplified interface.
Definition at line 417 of file nnet-optimize.cc.
References VariableMergingOptimizer::MergeVariables().
Referenced by Optimize().
void VectorizeNnet | ( | const Nnet & | src, |
VectorBase< BaseFloat > * | params | ||
) |
Copies the nnet parameters to *params, whose dimension must be equal to NumParameters(src).
Definition at line 378 of file nnet-utils.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), KALDI_ASSERT, KALDI_ERR, kUpdatableComponent, Nnet::NumComponents(), NumParameters(), UpdatableComponent::NumParameters(), Component::Properties(), and UpdatableComponent::Vectorize().
Definition at line 282 of file nnet-common.cc.
References rnnlm::i, kaldi::WriteBasicType(), WriteCindexVectorElementBinary(), and kaldi::WriteToken().
Referenced by UnitTestCindexIo(), and NnetComputation::MatrixDebugInfo::Write().
|
static |
Definition at line 162 of file nnet-common.cc.
References rnnlm::i, KALDI_ERR, Index::n, Index::t, kaldi::WriteBasicType(), and Index::x.
Referenced by WriteCindexVector().
|
static |
Definition at line 82 of file nnet3-xvector-get-egs.cc.
References NnetExample::Compress(), NnetIo::indexes, NnetExample::io, KALDI_ERR, KALDI_WARN, ChunkInfo::label, ChunkInfo::name, ChunkInfo::num_frames, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), ChunkInfo::output_archive_id, and ChunkInfo::start_frame.
Referenced by main().
Definition at line 126 of file nnet-common.cc.
References rnnlm::i, Index::Write(), kaldi::WriteBasicType(), WriteIndexVectorElementBinary(), and kaldi::WriteToken().
Referenced by IndexLessNxt::operator()(), UnitTestIndexIo(), kaldi::nnet3::time_height_convolution::UnitTestTimeHeightConvolutionCompile(), NnetIo::Write(), NnetDiscriminativeSupervision::Write(), IoSpecification::Write(), NnetChainSupervision::Write(), and NnetComputation::Write().
|
static |
Definition at line 45 of file nnet-common.cc.
References rnnlm::i, KALDI_ERR, Index::n, Index::t, kaldi::WriteBasicType(), and Index::x.
Referenced by WriteIndexVector().
void WriteVectorAsChar | ( | std::ostream & | os, |
bool | binary, | ||
const VectorBase< BaseFloat > & | vec | ||
) |
Definition at line 237 of file nnet-example-utils.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, VectorBase< Real >::Write(), and kaldi::WriteIntegerVector().
Referenced by NnetDiscriminativeSupervision::Write().
|
inline |
Definition at line 226 of file nnet-combined-component.cc.
References KALDI_PARANOID_ASSERT.
Referenced by ConvolutionComponent::InderivPatchesToInderiv(), and ConvolutionComponent::InputToInputPatches().
void ZeroComponentStats | ( | Nnet * | nnet | ) |
Zeroes the component stats in all nonlinear components in the nnet.
Definition at line 269 of file nnet-utils.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and Component::ZeroStats().
Referenced by NnetChainTrainer::NnetChainTrainer(), NnetDiscriminativeTrainer::NnetDiscriminativeTrainer(), NnetTrainer::NnetTrainer(), and RecomputeStats().
|
inline |
Definition at line 234 of file nnet-combined-component.cc.
References KALDI_PARANOID_ASSERT.
Referenced by ConvolutionComponent::InderivPatchesToInderiv(), and ConvolutionComponent::InputToInputPatches().
|
static |
Checks that we never use variables before they are allocated or after they are deallocated, and some other checks that can be done from the MatrixAccesses.
Definition at line 680 of file nnet-analyze.cc.
const int kNoTime = std::numeric_limits<int32>::min() |
Definition at line 573 of file nnet-common.cc.
Referenced by ComputationStepsComputer::Check(), ComputationLoopedOptimizer::CheckIdentifiedMatrices(), Compiler::ComputeInputLocationsList(), kaldi::nnet3::time_height_convolution::ConvolveForwardSimple(), RestrictedAttentionComponent::CreateIndexesVector(), MatrixExtender::FixDebugInfo(), RestrictedAttentionComponent::GetInputIndexes(), TimeHeightConvolutionComponent::GetInputIndexes(), TdnnComponent::GetInputIndexes(), GetTList(), RestrictedAttentionComponent::IsComputable(), TimeHeightConvolutionComponent::IsComputable(), TdnnComponent::IsComputable(), ComputationLoopedOptimizer::NormalizeCindexes(), Index::operator+=(), kaldi::nnet3::time_height_convolution::SetSomeIndexesBlank(), and kaldi::nnet3::time_height_convolution::ZeroBlankRows().