#include <nnet-nnet.h>
Public Member Functions | |
int32 | NumComponents () const |
Returns number of components– think of this as similar to # of layers, but e.g. More... | |
const Component & | GetComponent (int32 c) const |
Component & | GetComponent (int32 c) |
void | SetComponent (int32 c, Component *component) |
Sets the c'th component to "component", taking ownership of the pointer and deleting the corresponding one that we own. More... | |
int32 | LeftContext () const |
Returns the left-context summed over all the Components... More... | |
int32 | RightContext () const |
Returns the right-context summed over all the Components... More... | |
int32 | OutputDim () const |
The output dimension of the network – typically the number of pdfs. More... | |
int32 | InputDim () const |
Dimension of the input features, e.g. More... | |
void | ComputeChunkInfo (int32 input_chunk_size, int32 num_chunks, std::vector< ChunkInfo > *chunk_info_out) const |
Uses the output of the Context() functions of the network, to compute a vector of size NumComponents() + 1 indexed by component-index c, of the chunk-info at the input of each layer c, where the c+1'th element contains the chunk-info at the output of that layer. More... | |
void | ZeroStats () |
void | CopyStatsFrom (const Nnet &nnet) |
Copies only the statistics in layers of type NonlinearComponewnt, from this neural net, leaving everything else fixed. More... | |
int32 | FirstUpdatableComponent () const |
Returns the index of the lowest-numbered component which is updatable, or NumComponents() if none are updatable. More... | |
int32 | LastUpdatableComponent () const |
Returns the index of the highest-numbered component which is updatable, or -1 if none are updatable. More... | |
int32 | NumUpdatableComponents () const |
Returns the number of updatable components. More... | |
void | ScaleComponents (const VectorBase< BaseFloat > &scales) |
Scales the parameters of each of the updatable components. More... | |
void | RemoveDropout () |
Excise any components of type DropoutComponent or AdditiveNoiseComponent. More... | |
void | SetDropoutScale (BaseFloat scale) |
Calls SetDropoutScale for all the dropout nodes. More... | |
void | RemovePreconditioning () |
Replace any components of type AffineComponentPreconditioned with components of type AffineComponent. More... | |
void | SwitchToOnlinePreconditioning (int32 rank_in, int32 rank_out, int32 update_period, BaseFloat num_samples_history, BaseFloat alpha) |
Replaces any components of type AffineComponent or derived classes, with components of type AffineComponentPreconditionedOnline. More... | |
void | AddNnet (const VectorBase< BaseFloat > &scales, const Nnet &other) |
For each updatatable component, adds to it the corresponding element of "other" times the appropriate element of "scales" (which has the same format as for ScaleComponents(), i.e. More... | |
void | Scale (BaseFloat scale) |
Scales all the Components with the same scale. More... | |
void | AddNnet (BaseFloat alpha, const Nnet &other) |
Adds to *this, the other neural net times the scale "alpha". More... | |
void | LimitRankOfLastLayer (int32 dimension) |
Turns the last affine layer into two layers of the same type, with a smaller dimension in between– we're keeping the top singular values of the matrix. More... | |
void | AddNnet (BaseFloat alpha, Nnet *other, BaseFloat beta) |
This version of AddNnet adds to *this, alpha times *other, and then scales *other by beta. More... | |
void | Resize (int32 num_components) |
Removes final components from the neural network (used for debugging). More... | |
void | Collapse (bool match_updatableness) |
Where possible, collapse multiple affine or linear components in a sequence into a single one by composing the transforms. More... | |
void | SetIndexes () |
Sets the index_ values of the components. More... | |
Nnet (const Nnet &other) | |
Nnet (const Nnet &nnet1, const Nnet &nnet2) | |
Nnet () | |
Nnet & | operator= (const Nnet &other) |
void | Init (std::istream &is) |
Initialize from config file. More... | |
void | Init (std::vector< Component *> *components) |
This Init method works from a vector of components. More... | |
void | Append (Component *new_component) |
Appends this component to the components already in the neural net. More... | |
virtual | ~Nnet () |
std::string | Info () const |
void | Destroy () |
void | Write (std::ostream &os, bool binary) const |
void | Read (std::istream &is, bool binary) |
void | SetZero (bool treat_as_gradient) |
void | ResizeOutputLayer (int32 new_num_pdfs) |
This function is used when doing transfer learning to a new system. More... | |
void | ScaleLearningRates (BaseFloat factor) |
Scale all the learning rates in the neural net by this factor. More... | |
void | ScaleLearningRates (std::map< std::string, BaseFloat > scale_factors) |
Scale all the learning rates in the neural net by the factors indexed by the type of component. More... | |
void | SetLearningRates (BaseFloat learning_rates) |
Set all the learning rates in the neural net to this value. More... | |
void | SetLearningRates (const VectorBase< BaseFloat > &learning_rates) |
Set all the learning rates in the neural net to these values (one for each updatable layer). More... | |
void | GetLearningRates (VectorBase< BaseFloat > *learning_rates) const |
Get all the learning rates in the neural net (the output must have dim equal to NumUpdatableComponents()). More... | |
void | ComponentDotProducts (const Nnet &other, VectorBase< BaseFloat > *dot_prod) const |
void | Check () const |
void | ResetGenerators () |
virtual int32 | GetParameterDim () const |
virtual void | Vectorize (VectorBase< BaseFloat > *params) const |
virtual void | UnVectorize (const VectorBase< BaseFloat > ¶ms) |
Private Attributes | |
std::vector< Component * > | components_ |
Friends | |
class | NnetUpdater |
class | DecodableNnet |
Definition at line 63 of file nnet-nnet.h.
Definition at line 226 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, and Nnet::SetIndexes().
Definition at line 233 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, Nnet::InputDim(), KALDI_ERR, Nnet::OutputDim(), and Nnet::SetIndexes().
|
inline |
Definition at line 203 of file nnet-nnet.h.
References Nnet::Append(), Nnet::Init(), and Nnet::operator=().
Referenced by kaldi::nnet2::GenRandomNnet(), and Nnet::NumComponents().
|
inlinevirtual |
Definition at line 225 of file nnet-nnet.h.
References Nnet::Check(), Nnet::ComponentDotProducts(), Nnet::Destroy(), Nnet::GetLearningRates(), Nnet::GetParameterDim(), Nnet::Info(), Nnet::Read(), Nnet::ResetGenerators(), Nnet::ResizeOutputLayer(), Nnet::ScaleLearningRates(), Nnet::SetLearningRates(), Nnet::SetZero(), Nnet::UnVectorize(), Nnet::Vectorize(), and Nnet::Write().
void AddNnet | ( | const VectorBase< BaseFloat > & | scales, |
const Nnet & | other | ||
) |
For each updatatable component, adds to it the corresponding element of "other" times the appropriate element of "scales" (which has the same format as for ScaleComponents(), i.e.
one entry for each updatable component).
Definition at line 576 of file nnet-nnet.cc.
References UpdatableComponent::Add(), VectorBase< Real >::Dim(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, Nnet::NumComponents(), and Nnet::NumUpdatableComponents().
Referenced by kaldi::nnet2::AddDirection(), kaldi::nnet2::CombineNnets(), FastNnetCombiner::CombineNnets(), kaldi::nnet2::GetUpdateDirection(), main(), Nnet::NumComponents(), and DoBackpropParallelClass::~DoBackpropParallelClass().
Adds to *this, the other neural net times the scale "alpha".
This applies to UpdatableComponents, and (unlike the other AddNnet function) to SoftmaxComponents.
Definition at line 595 of file nnet-nnet.cc.
References UpdatableComponent::Add(), NonlinearComponent::Add(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, and Nnet::NumComponents().
This version of AddNnet adds to *this, alpha times *other, and then scales *other by beta.
The reason why we make this a separate function is for multithreading reasons (otherwise you could do AddNnet(alpha, *iter) and then other->Scale(beta).
Definition at line 617 of file nnet-nnet.cc.
References UpdatableComponent::Add(), NonlinearComponent::Add(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, Nnet::NumComponents(), UpdatableComponent::Scale(), and NonlinearComponent::Scale().
void Append | ( | Component * | new_component | ) |
Appends this component to the components already in the neural net.
Takes ownership of the pointer.
Definition at line 643 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, and Nnet::SetIndexes().
Referenced by kaldi::nnet2::GiveNnetCorrectTopology(), and Nnet::Nnet().
void Check | ( | ) | const |
Definition at line 271 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and KALDI_ASSERT.
Referenced by Nnet::Append(), Nnet::Collapse(), Nnet::Init(), Nnet::LimitRankOfLastLayer(), kaldi::nnet2::MixupNnet(), Nnet::Nnet(), Nnet::operator=(), Nnet::Read(), Nnet::RemoveDropout(), Nnet::RemovePreconditioning(), Nnet::ResizeOutputLayer(), Nnet::SetComponent(), Nnet::SwitchToOnlinePreconditioning(), kaldi::nnet2::WidenNnet(), Nnet::Write(), and Nnet::~Nnet().
void Collapse | ( | bool | match_updatableness | ) |
Where possible, collapse multiple affine or linear components in a sequence into a single one by composing the transforms.
If match_updatableness=true, this will not collapse, say, an AffineComponent with a FixedAffineComponent or FixedLinearComponent. If false, it will collapse them. This function won't necessarily work for all pairs of such layers. It currently only works where one of each pair is an AffineComponent.
Definition at line 730 of file nnet-nnet.cc.
References Nnet::Check(), AffineComponent::CollapseWithNext(), Nnet::components_, rnnlm::i, rnnlm::j, KALDI_LOG, and Nnet::SetIndexes().
Referenced by main(), and Nnet::NumComponents().
void ComponentDotProducts | ( | const Nnet & | other, |
VectorBase< BaseFloat > * | dot_prod | ||
) | const |
Definition at line 207 of file nnet-nnet.cc.
References Nnet::components_, VectorBase< Real >::Dim(), UpdatableComponent::DotProduct(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, and Nnet::NumUpdatableComponents().
Referenced by main(), and Nnet::~Nnet().
void ComputeChunkInfo | ( | int32 | input_chunk_size, |
int32 | num_chunks, | ||
std::vector< ChunkInfo > * | chunk_info_out | ||
) | const |
Uses the output of the Context() functions of the network, to compute a vector of size NumComponents() + 1 indexed by component-index c, of the chunk-info at the input of each layer c, where the c+1'th element contains the chunk-info at the output of that layer.
The "input_chunk_size" is the time extent of the input. If you want to produce exactly 1 output frame per chunk, then this should equal 1 + LeftContext() + RightContext().
Definition at line 65 of file nnet-nnet.cc.
References Nnet::components_, Component::Context(), Nnet::GetComponent(), rnnlm::i, Nnet::InputDim(), rnnlm::j, KALDI_ASSERT, Nnet::LeftContext(), Nnet::NumComponents(), Nnet::OutputDim(), and Nnet::RightContext().
Referenced by NnetOnlineComputer::Compute(), NnetUpdater::ComputeForMinibatch(), NnetOnlineComputer::Flush(), NnetRescaler::FormatInput(), NnetUpdater::FormatInput(), NnetComputer::NnetComputer(), NnetDiscriminativeUpdater::NnetDiscriminativeUpdater(), and Nnet::NumComponents().
void CopyStatsFrom | ( | const Nnet & | nnet | ) |
Copies only the statistics in layers of type NonlinearComponewnt, from this neural net, leaving everything else fixed.
Definition at line 447 of file nnet-nnet.cc.
References NonlinearComponent::Add(), Nnet::GetComponent(), rnnlm::i, KALDI_ASSERT, Nnet::NumComponents(), and NonlinearComponent::Scale().
Referenced by main(), and Nnet::NumComponents().
void Destroy | ( | ) |
Definition at line 200 of file nnet-nnet.cc.
References Nnet::components_.
Referenced by Nnet::Init(), Nnet::operator=(), Nnet::Read(), and Nnet::~Nnet().
int32 FirstUpdatableComponent | ( | ) | const |
Returns the index of the lowest-numbered component which is updatable, or NumComponents() if none are updatable.
Definition at line 828 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and Nnet::NumComponents().
Referenced by NnetUpdater::Backprop(), and Nnet::NumComponents().
Definition at line 141 of file nnet-nnet.cc.
References Nnet::components_, and KALDI_ASSERT.
Referenced by Nnet::AddNnet(), NnetStats::AddStatsFromNnet(), NnetComputer::Backprop(), NnetDiscriminativeUpdater::Backprop(), NnetUpdater::Backprop(), kaldi::nnet2::CombineNnetsA(), Nnet::ComponentDotProducts(), Nnet::ComputeChunkInfo(), kaldi::nnet2::ComputeObjfAndGradient(), FastNnetCombiner::ComputeObjfAndGradient(), NnetRescaler::ComputeRelevantIndexes(), Nnet::CopyStatsFrom(), kaldi::nnet2::FixNnet(), Nnet::GetLearningRates(), kaldi::nnet2::GetNnetStats(), Nnet::GetParameterDim(), NnetRescaler::GetTargetAvgDeriv(), kaldi::nnet2::GiveNnetCorrectTopology(), kaldi::nnet2::IndexOfSoftmaxLayer(), kaldi::nnet2::InsertComponents(), kaldi::nnet2::LimitRankParallel(), main(), Nnet::NumComponents(), Nnet::NumUpdatableComponents(), LimitRankClass::operator()(), FisherComputationClass::operator()(), NnetComputer::Propagate(), NnetDiscriminativeUpdater::Propagate(), NnetUpdater::Propagate(), NnetOnlineComputer::Propagate(), kaldi::nnet2::ReplaceLastComponents(), NnetRescaler::Rescale(), NnetRescaler::RescaleComponent(), Nnet::ResetGenerators(), Nnet::Scale(), Nnet::ScaleComponents(), Nnet::SetLearningRates(), kaldi::nnet2::SetMaxChange(), Nnet::UnVectorize(), Nnet::Vectorize(), and kaldi::nnet2::WidenNnet().
void GetLearningRates | ( | VectorBase< BaseFloat > * | learning_rates | ) | const |
Get all the learning rates in the neural net (the output must have dim equal to NumUpdatableComponents()).
Definition at line 476 of file nnet-nnet.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, UpdatableComponent::LearningRate(), Nnet::NumComponents(), and Nnet::NumUpdatableComponents().
Referenced by main(), and Nnet::~Nnet().
|
virtual |
Definition at line 657 of file nnet-nnet.cc.
References Nnet::GetComponent(), UpdatableComponent::GetParameterDim(), and Nnet::NumComponents().
Referenced by Nnet::Info(), main(), Nnet::UnVectorize(), Nnet::Vectorize(), and Nnet::~Nnet().
std::string Info | ( | ) | const |
Definition at line 257 of file nnet-nnet.cc.
References Nnet::components_, Nnet::GetParameterDim(), rnnlm::i, Nnet::InputDim(), Nnet::LeftContext(), Nnet::NumComponents(), Nnet::NumUpdatableComponents(), Nnet::OutputDim(), and Nnet::RightContext().
Referenced by kaldi::nnet2::DoBackprop(), AmNnet::Info(), main(), kaldi::nnet2::UnitTestNnetCompute(), kaldi::nnet2::UnitTestNnetComputeChunked(), and Nnet::~Nnet().
void Init | ( | std::istream & | is | ) |
Initialize from config file.
Each line of the config is either a comment line starting with whitespace then #, or it is a line that specifies one layer of the network, as accepted by Component::InitFromString(). An example non-comment line is: AffineComponent learning-rate=0.01 l2-penalty=0.001 input-dim=10 output-dim=15 param-stddev=0.1
Definition at line 281 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, Nnet::Destroy(), KALDI_ASSERT, Component::NewFromString(), and Nnet::SetIndexes().
Referenced by kaldi::nnet2::GenRandomNnet(), AmNnet::Init(), kaldi::nnet2::InsertComponents(), main(), Nnet::Nnet(), and kaldi::nnet2::ReplaceLastComponents().
void Init | ( | std::vector< Component *> * | components | ) |
This Init method works from a vector of components.
It will take ownership of the pointers and will resize the vector to zero to avoid a chance of the caller deallocating them (but the vector itself is not deleted).
Definition at line 305 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, Nnet::Destroy(), and Nnet::SetIndexes().
int32 InputDim | ( | ) | const |
Dimension of the input features, e.g.
13 or 40. Does not take account of frame splicing– that is done with the "chunk" mechanism, where you provide chunks of features over time.
Definition at line 36 of file nnet-nnet.cc.
References Nnet::components_, and KALDI_ASSERT.
Referenced by NnetOnlineComputer::Compute(), Nnet::ComputeChunkInfo(), NnetUpdater::ComputeForMinibatch(), NnetOnlineComputer::Flush(), NnetRescaler::FormatInput(), kaldi::nnet2::FormatNnetInput(), Nnet::Info(), Nnet::Nnet(), NnetComputer::NnetComputer(), and Nnet::NumComponents().
int32 LastUpdatableComponent | ( | ) | const |
Returns the index of the highest-numbered component which is updatable, or -1 if none are updatable.
Definition at line 837 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and Nnet::NumComponents().
Referenced by main(), and Nnet::NumComponents().
int32 LeftContext | ( | ) | const |
Returns the left-context summed over all the Components...
this is the entire left-context in frames, that the network requires.
Definition at line 42 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and KALDI_ASSERT.
Referenced by NnetOnlineComputer::Compute(), Nnet::ComputeChunkInfo(), NnetUpdater::ComputeForMinibatch(), DecodableAmNnet::DecodableAmNnet(), NnetOnlineComputer::Flush(), NnetRescaler::FormatInput(), NnetUpdater::FormatInput(), kaldi::nnet2::FormatNnetInput(), NnetDiscriminativeUpdater::GetInputFeatures(), Nnet::Info(), main(), kaldi::nnet2::NnetComputationChunked(), NnetComputer::NnetComputer(), Nnet::NumComponents(), kaldi::nnet2::UnitTestNnetCompute(), and kaldi::nnet2::UnitTestNnetComputeChunked().
void LimitRankOfLastLayer | ( | int32 | dimension | ) |
Turns the last affine layer into two layers of the same type, with a smaller dimension in between– we're keeping the top singular values of the matrix.
Definition at line 708 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, KALDI_ERR, AffineComponent::LimitRank(), and Nnet::SetIndexes().
Referenced by Nnet::NumComponents().
|
inline |
Returns number of components– think of this as similar to # of layers, but e.g.
the nonlinearity and the linear part count as separate components, so the number of components will be more than the number of layers.
Definition at line 69 of file nnet-nnet.h.
References Nnet::AddNnet(), Nnet::Collapse(), Nnet::components_, Nnet::ComputeChunkInfo(), Nnet::CopyStatsFrom(), Nnet::FirstUpdatableComponent(), Nnet::GetComponent(), Nnet::InputDim(), Nnet::LastUpdatableComponent(), Nnet::LeftContext(), Nnet::LimitRankOfLastLayer(), Nnet::Nnet(), Nnet::NumUpdatableComponents(), Nnet::OutputDim(), Nnet::RemoveDropout(), Nnet::RemovePreconditioning(), Nnet::Resize(), Nnet::RightContext(), Nnet::Scale(), Nnet::ScaleComponents(), Nnet::SetComponent(), Nnet::SetDropoutScale(), Nnet::SetIndexes(), Nnet::SwitchToOnlinePreconditioning(), and Nnet::ZeroStats().
Referenced by Nnet::AddNnet(), NnetComputer::Backprop(), NnetDiscriminativeUpdater::Backprop(), NnetUpdater::Backprop(), kaldi::nnet2::CombineNnetsA(), Nnet::ComputeChunkInfo(), NnetUpdater::ComputeForMinibatch(), NnetComputer::ComputeLastLayerDeriv(), NnetUpdater::ComputeObjfAndDeriv(), kaldi::nnet2::ComputeObjfAndGradient(), FastNnetCombiner::ComputeObjfAndGradient(), NnetRescaler::ComputeRelevantIndexes(), NnetUpdater::ComputeTotAccuracy(), Nnet::CopyStatsFrom(), Nnet::FirstUpdatableComponent(), kaldi::nnet2::FixNnet(), NnetUpdater::FormatInput(), Nnet::GetLearningRates(), kaldi::nnet2::GetNnetStats(), NnetUpdater::GetOutput(), Nnet::GetParameterDim(), kaldi::nnet2::GiveNnetCorrectTopology(), kaldi::nnet2::IndexOfSoftmaxLayer(), Nnet::Info(), kaldi::nnet2::InsertComponents(), Nnet::LastUpdatableComponent(), NnetDiscriminativeUpdater::LatticeComputations(), kaldi::nnet2::LimitRankParallel(), main(), NnetComputer::NnetComputer(), NnetOnlineComputer::NnetOnlineComputer(), Nnet::NumUpdatableComponents(), FisherComputationClass::operator()(), NnetComputer::Propagate(), NnetDiscriminativeUpdater::Propagate(), NnetOnlineComputer::Propagate(), NnetUpdater::Propagate(), kaldi::nnet2::ReplaceLastComponents(), NnetRescaler::Rescale(), Nnet::ResetGenerators(), Nnet::ResizeOutputLayer(), Nnet::Scale(), Nnet::ScaleComponents(), Nnet::ScaleLearningRates(), Nnet::SetLearningRates(), kaldi::nnet2::SetMaxChange(), Nnet::UnVectorize(), Nnet::Vectorize(), and kaldi::nnet2::WidenNnet().
int32 NumUpdatableComponents | ( | ) | const |
Returns the number of updatable components.
Definition at line 413 of file nnet-nnet.cc.
References Nnet::GetComponent(), rnnlm::i, and Nnet::NumComponents().
Referenced by Nnet::AddNnet(), Nnet::ComponentDotProducts(), FisherComputationClass::FisherComputationClass(), Nnet::GetLearningRates(), Nnet::Info(), main(), Nnet::NumComponents(), FisherComputationClass::operator()(), Nnet::ScaleComponents(), Nnet::SetLearningRates(), and kaldi::nnet2::ShrinkNnet().
Definition at line 247 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, Nnet::Destroy(), rnnlm::i, and Nnet::SetIndexes().
Referenced by Nnet::Nnet().
int32 OutputDim | ( | ) | const |
The output dimension of the network – typically the number of pdfs.
Definition at line 31 of file nnet-nnet.cc.
References Nnet::components_, and KALDI_ASSERT.
Referenced by Nnet::ComputeChunkInfo(), NnetUpdater::ComputeObjfAndDeriv(), Nnet::Info(), AmNnet::Init(), main(), Nnet::Nnet(), Nnet::NumComponents(), and AmNnet::NumPdfs().
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 175 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, Nnet::Destroy(), kaldi::ExpectToken(), kaldi::ReadBasicType(), Component::ReadNew(), and Nnet::SetIndexes().
Referenced by main(), AmNnet::Read(), kaldi::nnet2::UnitTestNnet(), and Nnet::~Nnet().
void RemoveDropout | ( | ) |
Excise any components of type DropoutComponent or AdditiveNoiseComponent.
Definition at line 497 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, KALDI_LOG, and Nnet::SetIndexes().
Referenced by main(), and Nnet::NumComponents().
void RemovePreconditioning | ( | ) |
Replace any components of type AffineComponentPreconditioned with components of type AffineComponent.
Definition at line 531 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, and Nnet::SetIndexes().
Referenced by main(), and Nnet::NumComponents().
void ResetGenerators | ( | ) |
Definition at line 683 of file nnet-nnet.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and RandomComponent::ResetGenerator().
Referenced by Nnet::~Nnet().
void Resize | ( | int32 | num_components | ) |
Removes final components from the neural network (used for debugging).
Definition at line 490 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and KALDI_ASSERT.
Referenced by main(), and Nnet::NumComponents().
void ResizeOutputLayer | ( | int32 | new_num_pdfs | ) |
This function is used when doing transfer learning to a new system.
It resizes the final affine and softmax components. If your system has a SumGroupComponent before the final softmax, it will be discarded.
Definition at line 356 of file nnet-nnet.cc.
References Nnet::Check(), AffineComponent::CollapseWithNext(), Nnet::components_, AffineComponent::InputDim(), KALDI_ASSERT, KALDI_ERR, Nnet::NumComponents(), AffineComponent::Resize(), and Nnet::SetIndexes().
Referenced by AmNnet::ResizeOutputLayer(), and Nnet::~Nnet().
int32 RightContext | ( | ) | const |
Returns the right-context summed over all the Components...
this is the entire right-context in frames, that the network requires.
Definition at line 56 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and KALDI_ASSERT.
Referenced by NnetOnlineComputer::Compute(), Nnet::ComputeChunkInfo(), NnetUpdater::ComputeForMinibatch(), DecodableAmNnet::DecodableAmNnet(), NnetOnlineComputer::Flush(), NnetRescaler::FormatInput(), NnetUpdater::FormatInput(), kaldi::nnet2::FormatNnetInput(), NnetDiscriminativeUpdater::GetInputFeatures(), Nnet::Info(), main(), kaldi::nnet2::NnetComputationChunked(), NnetComputer::NnetComputer(), Nnet::NumComponents(), kaldi::nnet2::UnitTestNnetCompute(), and kaldi::nnet2::UnitTestNnetComputeChunked().
void Scale | ( | BaseFloat | scale | ) |
Scales all the Components with the same scale.
This applies to UpdatableComponents, and (unlike the ScaleComponents function) to SoftmaxComponents.
Definition at line 436 of file nnet-nnet.cc.
References Nnet::GetComponent(), rnnlm::i, Nnet::NumComponents(), UpdatableComponent::Scale(), and NonlinearComponent::Scale().
Referenced by main(), and Nnet::NumComponents().
void ScaleComponents | ( | const VectorBase< BaseFloat > & | scales | ) |
Scales the parameters of each of the updatable components.
Here, scale_params is a vector of size equal to NumUpdatableComponents()
Definition at line 421 of file nnet-nnet.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, Nnet::NumComponents(), Nnet::NumUpdatableComponents(), and UpdatableComponent::Scale().
Referenced by kaldi::nnet2::CombineNnets(), FastNnetCombiner::CombineNnets(), kaldi::nnet2::ComputeObjfAndGradient(), kaldi::nnet2::GetUpdateDirection(), main(), Nnet::NumComponents(), and kaldi::nnet2::ShrinkNnet().
void ScaleLearningRates | ( | BaseFloat | factor | ) |
Scale all the learning rates in the neural net by this factor.
Definition at line 313 of file nnet-nnet.cc.
References Nnet::components_, KALDI_LOG, UpdatableComponent::LearningRate(), Nnet::NumComponents(), and UpdatableComponent::SetLearningRate().
Referenced by main(), and Nnet::~Nnet().
void ScaleLearningRates | ( | std::map< std::string, BaseFloat > | scale_factors | ) |
Scale all the learning rates in the neural net by the factors indexed by the type of component.
Definition at line 327 of file nnet-nnet.cc.
References Nnet::components_, KALDI_LOG, UpdatableComponent::LearningRate(), Nnet::NumComponents(), UpdatableComponent::SetLearningRate(), and Component::Type().
Sets the c'th component to "component", taking ownership of the pointer and deleting the corresponding one that we own.
Definition at line 649 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, KALDI_ASSERT, and Nnet::SetIndexes().
Referenced by Nnet::NumComponents().
void SetDropoutScale | ( | BaseFloat | scale | ) |
Calls SetDropoutScale for all the dropout nodes.
Definition at line 516 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, KALDI_LOG, and DropoutComponent::SetDropoutScale().
Referenced by main(), and Nnet::NumComponents().
void SetIndexes | ( | ) |
Sets the index_ values of the components.
Definition at line 725 of file nnet-nnet.cc.
References Nnet::components_, and rnnlm::i.
Referenced by Nnet::Append(), Nnet::Collapse(), Nnet::Init(), Nnet::LimitRankOfLastLayer(), Nnet::Nnet(), Nnet::NumComponents(), Nnet::operator=(), Nnet::Read(), Nnet::RemoveDropout(), Nnet::RemovePreconditioning(), Nnet::ResizeOutputLayer(), Nnet::SetComponent(), and Nnet::SwitchToOnlinePreconditioning().
void SetLearningRates | ( | BaseFloat | learning_rates | ) |
Set all the learning rates in the neural net to this value.
Definition at line 346 of file nnet-nnet.cc.
References Nnet::components_, KALDI_LOG, Nnet::NumComponents(), and UpdatableComponent::SetLearningRate().
Referenced by main(), and Nnet::~Nnet().
void SetLearningRates | ( | const VectorBase< BaseFloat > & | learning_rates | ) |
Set all the learning rates in the neural net to these values (one for each updatable layer).
Definition at line 461 of file nnet-nnet.cc.
References VectorBase< Real >::Dim(), Nnet::GetComponent(), rnnlm::i, rnnlm::j, KALDI_ASSERT, VectorBase< Real >::Min(), Nnet::NumComponents(), Nnet::NumUpdatableComponents(), and UpdatableComponent::SetLearningRate().
void SetZero | ( | bool | treat_as_gradient | ) |
Definition at line 151 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, NonlinearComponent::Scale(), and UpdatableComponent::SetZero().
Referenced by kaldi::nnet2::ComputeNnetGradient(), kaldi::nnet2::ComputeObjfAndGradient(), FastNnetCombiner::ComputeObjfAndGradient(), DoBackpropParallelClass::DoBackpropParallelClass(), main(), FisherComputationClass::operator()(), and Nnet::~Nnet().
void SwitchToOnlinePreconditioning | ( | int32 | rank_in, |
int32 | rank_out, | ||
int32 | update_period, | ||
BaseFloat | num_samples_history, | ||
BaseFloat | alpha | ||
) |
Replaces any components of type AffineComponent or derived classes, with components of type AffineComponentPreconditionedOnline.
E.g. rank_in = 20, rank_out = 80, num_samples_history = 2000.0, alpha = 4.0
Definition at line 551 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, rnnlm::i, KALDI_LOG, and Nnet::SetIndexes().
Referenced by main(), and Nnet::NumComponents().
|
virtual |
Definition at line 694 of file nnet-nnet.cc.
References Nnet::GetComponent(), Nnet::GetParameterDim(), UpdatableComponent::GetParameterDim(), KALDI_ASSERT, Nnet::NumComponents(), VectorBase< Real >::Range(), and UpdatableComponent::UnVectorize().
Referenced by Nnet::~Nnet().
|
virtual |
Definition at line 668 of file nnet-nnet.cc.
References Nnet::GetComponent(), Nnet::GetParameterDim(), UpdatableComponent::GetParameterDim(), KALDI_ASSERT, Nnet::NumComponents(), and UpdatableComponent::Vectorize().
Referenced by Nnet::~Nnet().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 160 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by kaldi::nnet2::UnitTestNnet(), AmNnet::Write(), and Nnet::~Nnet().
void ZeroStats | ( | ) |
Definition at line 192 of file nnet-nnet.cc.
References Nnet::components_, rnnlm::i, and NonlinearComponent::Scale().
Referenced by main(), and Nnet::NumComponents().
|
friend |
Definition at line 288 of file nnet-nnet.h.
|
friend |
Definition at line 287 of file nnet-nnet.h.
|
private |
Definition at line 290 of file nnet-nnet.h.
Referenced by Nnet::Append(), Nnet::Check(), Nnet::Collapse(), Nnet::ComponentDotProducts(), Nnet::ComputeChunkInfo(), Nnet::Destroy(), Nnet::FirstUpdatableComponent(), Nnet::GetComponent(), Nnet::Info(), Nnet::Init(), Nnet::InputDim(), Nnet::LastUpdatableComponent(), Nnet::LeftContext(), Nnet::LimitRankOfLastLayer(), Nnet::Nnet(), Nnet::NumComponents(), Nnet::operator=(), Nnet::OutputDim(), Nnet::Read(), Nnet::RemoveDropout(), Nnet::RemovePreconditioning(), Nnet::Resize(), Nnet::ResizeOutputLayer(), Nnet::RightContext(), Nnet::ScaleLearningRates(), Nnet::SetComponent(), Nnet::SetDropoutScale(), Nnet::SetIndexes(), Nnet::SetLearningRates(), Nnet::SetZero(), Nnet::SwitchToOnlinePreconditioning(), Nnet::Write(), and Nnet::ZeroStats().