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().