#include <nnet-nnet.h>
Public Member Functions | |
void | ReadConfig (std::istream &config_file) |
int32 | NumComponents () const |
int32 | NumNodes () const |
Component * | GetComponent (int32 c) |
Return component indexed c. Not a copy; not owned by caller. More... | |
const Component * | GetComponent (int32 c) const |
Return component indexed c (const version). More... | |
void | SetComponent (int32 c, Component *component) |
Replace the component indexed by c with a new component. More... | |
int32 | AddComponent (const std::string &name, Component *component) |
Adds a new component with the given name, which should not be the same as any existing component name. More... | |
const NetworkNode & | GetNode (int32 node) const |
returns const reference to a particular numbered network node. More... | |
NetworkNode & | GetNode (int32 node) |
Non-const accessor for the node... use with extreme caution. More... | |
bool | IsComponentNode (int32 node) const |
Returns true if this is a component node, meaning that it is of type kComponent. More... | |
bool | IsDimRangeNode (int32 node) const |
Returns true if this is a dim-range node, meaning that it is of type kDimRange. More... | |
bool | IsInputNode (int32 node) const |
Returns true if this is an output node, meaning that it is of type kInput. More... | |
bool | IsDescriptorNode (int32 node) const |
Returns true if this is a descriptor node, meaning that it is of type kDescriptor. More... | |
bool | IsOutputNode (int32 node) const |
Returns true if this is an output node, meaning that it is of type kDescriptor and is not directly followed by a node of type kComponent. More... | |
bool | IsComponentInputNode (int32 node) const |
Returns true if this is component-input node, i.e. More... | |
const std::vector< std::string > & | GetNodeNames () const |
returns vector of node names (needed by some parsing code, for instance). More... | |
const std::string & | GetNodeName (int32 node_index) const |
returns individual node name. More... | |
void | SetNodeName (int32 node_index, const std::string &new_name) |
This can be used to modify invidual node names. More... | |
const std::vector< std::string > & | GetComponentNames () const |
returns vector of component names (needed by some parsing code, for instance). More... | |
const std::string & | GetComponentName (int32 component_index) const |
returns individual component name. More... | |
int32 | GetNodeIndex (const std::string &node_name) const |
returns index associated with this node name, or -1 if no such index. More... | |
int32 | GetComponentIndex (const std::string &node_name) const |
returns index associated with this component name, or -1 if no such index. More... | |
int32 | InputDim (const std::string &input_name) const |
int32 | OutputDim (const std::string &output_name) const |
void | Read (std::istream &istream, bool binary) |
void | Write (std::ostream &ostream, bool binary) const |
void | Check (bool warn_for_orphans=true) const |
Checks the neural network for validity (dimension matches and various other requirements). More... | |
std::string | Info () const |
returns some human-readable information about the network, mostly for debugging purposes. More... | |
int32 | Modulus () const |
[Relevant for clockwork RNNs and similar]. More... | |
~Nnet () | |
Nnet () | |
Nnet (const Nnet &nnet) | |
Nnet * | Copy () const |
void | Swap (Nnet *other) |
Nnet & | operator= (const Nnet &nnet) |
void | RemoveOrphanNodes (bool remove_orphan_inputs=false) |
void | RemoveOrphanComponents () |
void | RemoveSomeNodes (const std::vector< int32 > &nodes_to_remove) |
void | ResetGenerators () |
void | GetConfigLines (bool include_dim, std::vector< std::string > *config_lines) const |
Private Member Functions | |
void | Destroy () |
std::string | GetAsConfigLine (int32 node_index, bool include_dim) const |
void | ProcessComponentConfigLine (int32 initial_num_components, ConfigLine *config) |
void | ProcessComponentNodeConfigLine (int32 pass, ConfigLine *config) |
void | ProcessInputNodeConfigLine (ConfigLine *config) |
void | ProcessOutputNodeConfigLine (int32 pass, ConfigLine *config) |
void | ProcessDimRangeNodeConfigLine (int32 pass, ConfigLine *config) |
void | GetSomeNodeNames (std::vector< std::string > *modified_node_names) const |
Static Private Member Functions | |
static void | RemoveRedundantConfigLines (int32 num_lines_initial, std::vector< ConfigLine > *config_lines) |
Private Attributes | |
std::vector< std::string > | component_names_ |
std::vector< Component * > | components_ |
std::vector< std::string > | node_names_ |
std::vector< NetworkNode > | nodes_ |
Definition at line 115 of file nnet-nnet.h.
|
inline |
Definition at line 237 of file nnet-nnet.h.
|
inline |
Definition at line 240 of file nnet-nnet.h.
Definition at line 797 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::components_, and rnnlm::i.
Adds a new component with the given name, which should not be the same as any existing component name.
Returns the new component index. Takes ownership of the pointer 'component'.
Definition at line 161 of file nnet-nnet.cc.
References kaldi::IsValidName(), and KALDI_ASSERT.
Referenced by ModelCollapser::CollapseComponentsAffine(), ModelCollapser::CollapseComponentsScale(), SvdApplier::DecomposeComponents(), ModelCollapser::GetDiagonallyPreModifiedComponentIndex(), and ModelCollapser::GetScaledComponentIndex().
void Check | ( | bool | warn_for_orphans = true | ) | const |
Checks the neural network for validity (dimension matches and various other requirements).
You can call this with warn_for_orphans = false to disable the warnings that are printed if orphan nodes or components exist.
Definition at line 694 of file nnet-nnet.cc.
References NetworkNode::component_index, NetworkNode::descriptor, NetworkNode::dim, NetworkNode::Dim(), NetworkNode::dim_offset, kaldi::nnet3::FindOrphanComponents(), kaldi::nnet3::FindOrphanNodes(), Descriptor::GetNodeDependencies(), rnnlm::i, Component::InputDim(), KALDI_ASSERT, KALDI_ERR, KALDI_WARN, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, rnnlm::n, NetworkNode::node_index, NetworkNode::node_type, kaldi::SortAndUniq(), and NetworkNode::u.
Referenced by Nnet::Nnet(), Nnet::operator=(), Nnet::RemoveOrphanComponents(), and Nnet::RemoveSomeNodes().
|
inline |
Definition at line 246 of file nnet-nnet.h.
References kaldi::nnet3::ResetGenerators().
Referenced by NnetChainTrainer::NnetChainTrainer(), NnetDiscriminativeTrainer::NnetDiscriminativeTrainer(), and NnetTrainer::NnetTrainer().
|
private |
Definition at line 554 of file nnet-nnet.cc.
References rnnlm::i.
Referenced by Nnet::operator=().
Definition at line 71 of file nnet-nnet.cc.
References KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, kaldi::nnet3::kLinear, NetworkNode::node_index, and NetworkNode::node_type.
Return component indexed c. Not a copy; not owned by caller.
Definition at line 150 of file nnet-nnet.cc.
References KALDI_ASSERT.
Referenced by Compiler::AddBackwardStepComponent(), ComputationGraphBuilder::AddDependencies(), Compiler::AddForwardStepComponent(), kaldi::nnet3::AddNnet(), kaldi::nnet3::AddNnetComponents(), kaldi::nnet3::ApplyL2Regularization(), ComputationChecker::CheckComputationCompression(), ComputationChecker::CheckComputationIndexes(), ModelCollapser::CollapseComponentsAffine(), ModelCollapser::CollapseComponentsBatchnorm(), ModelCollapser::CollapseComponentsDropout(), ModelCollapser::CollapseComponentsScale(), kaldi::nnet3::ComponentDotProducts(), kaldi::nnet3::ComputeCommandAttributes(), ComputationGraphBuilder::ComputeComputableInfo(), kaldi::nnet3::ComputeComputationGraph(), Compiler::ComputeDerivNeeded(), ComputationExpander::ComputePrecomputedIndexes(), kaldi::nnet3::ConsolidateMemory(), ModelUpdateConsolidator::ConsolidateModelUpdate(), kaldi::nnet3::ConstrainOrthonormal(), kaldi::nnet3::ConvertRepeatedToBlockAffine(), NnetComputer::DebugAfterExecute(), NnetComputer::DebugBeforeExecute(), SvdApplier::DecomposeComponents(), NetworkNode::Dim(), kaldi::nnet3::DotProduct(), NnetComputer::ExecuteCommand(), kaldi::nnet3::FreezeNaturalGradient(), ModelCollapser::GetDiagonallyPreModifiedComponentIndex(), ModelCollapser::GetScaledComponentIndex(), Compiler::GetStrideType(), kaldi::nnet3::HasBatchnorm(), VariableMergingOptimizer::MergeVariables(), DerivativeTimeLimiter::ModifyCommand(), kaldi::nnet3::NnetParametersAreIdentical(), kaldi::nnet3::NumParameters(), kaldi::nnet3::NumUpdatableComponents(), kaldi::nnet3::PerturbParams(), MaxChangeStats::Print(), kaldi::nnet3::PrintVectorPerUpdatableComponent(), ComputationStepsComputer::ProcessComponentStep(), MemoryCompressionOptimizer::ProcessMatrix(), kaldi::nnet3::ReadEditConfig(), kaldi::nnet3::ReduceRankOfComponents(), Nnet::ResetGenerators(), kaldi::nnet3::ResetGenerators(), kaldi::nnet3::ScaleBatchnormStats(), kaldi::nnet3::ScaleNnet(), kaldi::nnet3::SetBatchnormTestMode(), kaldi::nnet3::SetDropoutProportion(), kaldi::nnet3::SetDropoutTestMode(), kaldi::nnet3::SetLearningRate(), kaldi::nnet3::SetNnetAsGradient(), kaldi::nnet3::SetRequireDirectInput(), Compiler::SetUpPrecomputedIndexes(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffine(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffineComposite(), kaldi::nnet3::UnVectorizeNnet(), kaldi::nnet3::UpdateNnetWithMaxChange(), kaldi::nnet3::VectorizeNnet(), and kaldi::nnet3::ZeroComponentStats().
Return component indexed c (const version).
Not a copy; not owned by caller.
Definition at line 145 of file nnet-nnet.cc.
References KALDI_ASSERT.
int32 GetComponentIndex | ( | const std::string & | node_name | ) | const |
returns index associated with this component name, or -1 if no such index.
Definition at line 474 of file nnet-nnet.cc.
References rnnlm::i.
Referenced by ModelCollapser::CollapseComponentsAffine(), ModelCollapser::CollapseComponentsScale(), SvdApplier::DecomposeComponents(), ModelCollapser::GetDiagonallyPreModifiedComponentIndex(), and ModelCollapser::GetScaledComponentIndex().
const std::string & GetComponentName | ( | int32 | component_index | ) | const |
returns individual component name.
Definition at line 689 of file nnet-nnet.cc.
References NetworkNode::component_index, and KALDI_ASSERT.
Referenced by ModelCollapser::CollapseComponentsAffine(), ModelCollapser::CollapseComponentsBatchnorm(), ModelCollapser::CollapseComponentsScale(), NnetComputer::DebugAfterExecute(), SvdApplier::DecomposeComponents(), NnetComputer::ExecuteCommand(), ModelCollapser::GetDiagonallyPreModifiedComponentIndex(), ModelCollapser::GetScaledComponentIndex(), SvdApplier::ModifyTopology(), kaldi::nnet3::NnetParametersAreIdentical(), MaxChangeStats::Print(), kaldi::nnet3::PrintCommand(), kaldi::nnet3::PrintVectorPerUpdatableComponent(), kaldi::nnet3::ReadEditConfig(), kaldi::nnet3::ReduceRankOfComponents(), and kaldi::nnet3::UpdateNnetWithMaxChange().
const std::vector< std::string > & GetComponentNames | ( | ) | const |
returns vector of component names (needed by some parsing code, for instance).
Definition at line 67 of file nnet-nnet.cc.
void GetConfigLines | ( | bool | include_dim, |
std::vector< std::string > * | config_lines | ||
) | const |
Definition at line 180 of file nnet-nnet.cc.
References rnnlm::n.
Referenced by Nnet::Info(), and kaldi::nnet3::ModifyNnetIvectorPeriod().
|
inline |
returns const reference to a particular numbered network node.
Definition at line 146 of file nnet-nnet.h.
References KALDI_ASSERT.
Referenced by Compiler::AddBackwardStepComponent(), Compiler::AddBackwardStepInput(), ComputationGraphBuilder::AddDependencies(), Compiler::AddForwardStepComponent(), Compiler::AddForwardStepInput(), kaldi::nnet3::computation_graph::AddInputToGraph(), Compiler::CompileBackward(), Compiler::CompileBackwardSumDescriptor(), Compiler::CompileForward(), Compiler::CompileForwardSumDescriptor(), ComputationGraphBuilder::ComputeComputableInfo(), kaldi::nnet3::ComputeComputationGraph(), Compiler::ComputeDerivNeeded(), Compiler::ComputeInputLocationsList(), Compiler::CreateStepInfo(), SimpleForwardingDescriptor::Dim(), kaldi::nnet3::FindOrphanComponents(), Compiler::GetStrideType(), Compiler::IsInputStep(), SvdApplier::ModifyTopology(), kaldi::nnet3::NnetToDirectedGraph(), ModelCollapser::OptimizeNode(), NnetComputeProb::PrintTotalStats(), ComputationStepsComputer::ProcessComponentStep(), ComputationStepsComputer::ProcessDimRangeSubPhase(), NnetComputeProb::ProcessOutputs(), NnetTrainer::ProcessOutputs(), and Compiler::SetUpPrecomputedIndexes().
|
inline |
Non-const accessor for the node... use with extreme caution.
Definition at line 152 of file nnet-nnet.h.
References NetworkNode::component_index, KALDI_ASSERT, and NetworkNode::node_index.
int32 GetNodeIndex | ( | const std::string & | node_name | ) | const |
returns index associated with this node name, or -1 if no such index.
Definition at line 466 of file nnet-nnet.cc.
References rnnlm::i.
Referenced by NnetComputer::AcceptInputs(), kaldi::nnet3::computation_graph::AddInputToGraph(), kaldi::nnet3::computation_graph::AddOutputToGraph(), kaldi::nnet3::ComputeSimpleNnetContextForShift(), kaldi::nnet3::GetChainComputationRequest(), ComputationGraphBuilder::GetComputableInfo(), kaldi::nnet3::GetComputationRequest(), kaldi::nnet3::GetDiscriminativeComputationRequest(), NnetComputer::GetIoMatrixIndex(), kaldi::nnet3::HasXentOutputs(), kaldi::nnet3::IsSimpleNnet(), NnetDiscriminativeComputeObjf::PrintTotalStats(), NnetChainComputeProb::PrintTotalStats(), NnetComputeProb::PrintTotalStats(), NnetDiscriminativeComputeObjf::ProcessOutputs(), NnetChainTrainer::ProcessOutputs(), NnetChainComputeProb::ProcessOutputs(), NnetDiscriminativeTrainer::ProcessOutputs(), NnetComputeProb::ProcessOutputs(), NnetTrainer::ProcessOutputs(), and kaldi::nnet3::ReadEditConfig().
const std::string & GetNodeName | ( | int32 | node_index | ) | const |
returns individual node name.
Definition at line 684 of file nnet-nnet.cc.
References KALDI_ASSERT, and NetworkNode::node_index.
Referenced by NnetComputer::CheckNoPendingIo(), kaldi::nnet3::PrintCommand(), ComputationStepsComputer::ProcessInputOrOutputStep(), and kaldi::nnet3::ReadEditConfig().
const std::vector< std::string > & GetNodeNames | ( | ) | const |
returns vector of node names (needed by some parsing code, for instance).
Definition at line 63 of file nnet-nnet.cc.
Referenced by Compiler::ComputeDerivNeeded(), Compiler::DeallocateMatrices(), kaldi::nnet3::EvaluateComputationRequest(), kaldi::nnet3::HasXentOutputs(), SvdApplier::ModifyTopology(), kaldi::nnet3::PrintComputationPreamble(), and ModelCollapser::ReplaceNodeInDescriptor().
|
private |
Definition at line 563 of file nnet-nnet.cc.
References rnnlm::i, kaldi::nnet3::kComponent, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, and NetworkNode::node_type.
std::string Info | ( | ) | const |
returns some human-readable information about the network, mostly for debugging purposes.
Also see function NnetInfo() in nnet-utils.h, which prints out more extensive infoformation.
Definition at line 821 of file nnet-nnet.cc.
References Nnet::component_names_, Nnet::components_, kaldi::nnet3::ComputeSimpleNnetContext(), Nnet::GetConfigLines(), rnnlm::i, kaldi::nnet3::IsSimpleNnet(), Nnet::Modulus(), and kaldi::nnet3::NumParameters().
Referenced by AmNnetSimple::Info(), main(), kaldi::nnet3::NnetInfo(), kaldi::nnet3::TestNnetDecodable(), and kaldi::nnet3::UnitTestNnetCompileLooped().
int32 InputDim | ( | const std::string & | input_name | ) | const |
Definition at line 669 of file nnet-nnet.cc.
References NetworkNode::dim, kaldi::nnet3::kInput, rnnlm::n, and NetworkNode::node_type.
Referenced by BatchedXvectorComputer::BatchedXvectorComputer(), kaldi::nnet3::ComputeExampleComputationRequestSimple(), kaldi::nnet3::CreateLoopedComputationRequest(), DecodableNnetLoopedOnlineBase::DecodableNnetLoopedOnlineBase(), AmNnetSimple::Info(), DecodableNnetSimpleLoopedInfo::Init(), AmNnetSimple::InputDim(), AmNnetSimple::IvectorDim(), NnetBatchComputer::NnetBatchComputer(), kaldi::nnet3::NnetInfo(), and kaldi::nnet3::TestNnetDecodable().
Returns true if this is component-input node, i.e.
a node of type kDescriptor that immediately precedes a node of type kComponent.
Definition at line 172 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, and NetworkNode::node_type.
Referenced by Compiler::GetStrideType(), SvdApplier::ModifyTopology(), ComputationStepsComputer::ProcessSubPhase(), and Nnet::RemoveOrphanNodes().
Returns true if this is a component node, meaning that it is of type kComponent.
Definition at line 132 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kComponent, and NetworkNode::node_type.
Referenced by Compiler::ComputeDerivNeeded(), Compiler::ComputeStepDependencies(), kaldi::nnet3::FindOrphanComponents(), Compiler::GetStrideType(), SvdApplier::ModifyTopology(), ComputationStepsComputer::ProcessComponentStep(), ComputationStepsComputer::ProcessSubPhase(), and Nnet::RemoveOrphanComponents().
Returns true if this is a descriptor node, meaning that it is of type kDescriptor.
Exactly one of IsOutput or IsComponentInput will also apply.
Definition at line 126 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kDescriptor, and NetworkNode::node_type.
Returns true if this is a dim-range node, meaning that it is of type kDimRange.
Definition at line 138 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kDimRange, and NetworkNode::node_type.
Referenced by ComputationStepsComputer::ProcessDimRangeSubPhase(), and ComputationStepsComputer::ProcessSubPhase().
Returns true if this is an output node, meaning that it is of type kInput.
Definition at line 120 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kInput, and NetworkNode::node_type.
Referenced by NnetComputer::AcceptInputs(), ComputationChecker::CheckComputationIndexes(), Compiler::DeallocateMatrices(), kaldi::nnet3::GetChainComputationRequest(), kaldi::nnet3::GetComputationRequest(), kaldi::nnet3::GetDiscriminativeComputationRequest(), kaldi::nnet3::IsSimpleNnet(), SvdApplier::ModifyTopology(), kaldi::nnet3::NumInputNodes(), ComputationStepsComputer::ProcessInputOrOutputStep(), ComputationStepsComputer::ProcessSubPhase(), and Nnet::RemoveOrphanNodes().
Returns true if this is an output node, meaning that it is of type kDescriptor and is not directly followed by a node of type kComponent.
Definition at line 112 of file nnet-nnet.cc.
References KALDI_ASSERT, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, and NetworkNode::node_type.
Referenced by Compiler::AllocateMatrices(), ComputationGraphBuilder::Check(), ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardDescriptor(), Compiler::CompileForwardDescriptor(), Compiler::ComputeDerivNeeded(), ComputationGraphBuilder::ComputeRequiredArray(), Compiler::DeallocateMatrices(), kaldi::nnet3::FindOrphanNodes(), kaldi::nnet3::GetChainComputationRequest(), kaldi::nnet3::GetComputationRequest(), kaldi::nnet3::GetDiscriminativeComputationRequest(), kaldi::nnet3::HasXentOutputs(), kaldi::nnet3::IsSimpleNnet(), SvdApplier::ModifyTopology(), kaldi::nnet3::NumOutputNodes(), ComputationStepsComputer::ProcessInputOrOutputStep(), NnetDiscriminativeComputeObjf::ProcessOutputs(), NnetChainTrainer::ProcessOutputs(), NnetChainComputeProb::ProcessOutputs(), NnetDiscriminativeTrainer::ProcessOutputs(), NnetComputeProb::ProcessOutputs(), NnetTrainer::ProcessOutputs(), ComputationStepsComputer::ProcessSubPhase(), and kaldi::nnet3::ReadEditConfig().
int32 Modulus | ( | ) | const |
[Relevant for clockwork RNNs and similar].
Computes the smallest integer n >=1 such that the neural net's behavior will be the same if we shift the input and output's time indexes (t) by integer multiples of n. Does this by computing the lcm of all the moduli of the Descriptors in the network.
Definition at line 658 of file nnet-nnet.cc.
References NetworkNode::descriptor, kaldi::nnet3::kDescriptor, kaldi::Lcm(), Descriptor::Modulus(), rnnlm::n, and NetworkNode::node_type.
Referenced by kaldi::nnet3::ComputeSimpleNnetContext(), kaldi::nnet3::ComputeSimpleNnetContextForShift(), kaldi::nnet3::CreateLoopedComputationRequest(), kaldi::nnet3::GetChunkSize(), Nnet::Info(), and NnetBatchComputer::NnetBatchComputer().
|
inline |
Definition at line 124 of file nnet-nnet.h.
Referenced by kaldi::nnet3::AddNnet(), kaldi::nnet3::AddNnetComponents(), kaldi::nnet3::ApplyL2Regularization(), ComputationChecker::CheckComputationIndexes(), ModelCollapser::Collapse(), kaldi::nnet3::ComponentDotProducts(), kaldi::nnet3::ConsolidateMemory(), ModelUpdateConsolidator::ConsolidateModelUpdate(), kaldi::nnet3::ConstrainOrthonormal(), kaldi::nnet3::ConvertRepeatedToBlockAffine(), SvdApplier::DecomposeComponents(), kaldi::nnet3::DotProduct(), kaldi::nnet3::FindOrphanComponents(), kaldi::nnet3::FreezeNaturalGradient(), kaldi::nnet3::HasBatchnorm(), kaldi::nnet3::NnetParametersAreIdentical(), kaldi::nnet3::NumParameters(), kaldi::nnet3::NumUpdatableComponents(), kaldi::nnet3::PerturbParams(), MaxChangeStats::Print(), kaldi::nnet3::PrintVectorPerUpdatableComponent(), kaldi::nnet3::ReadEditConfig(), kaldi::nnet3::ReduceRankOfComponents(), Nnet::ResetGenerators(), kaldi::nnet3::ResetGenerators(), kaldi::nnet3::ScaleBatchnormStats(), kaldi::nnet3::ScaleNnet(), kaldi::nnet3::SetBatchnormTestMode(), kaldi::nnet3::SetDropoutProportion(), kaldi::nnet3::SetDropoutTestMode(), kaldi::nnet3::SetLearningRate(), kaldi::nnet3::SetNnetAsGradient(), kaldi::nnet3::SetRequireDirectInput(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffine(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffineComposite(), kaldi::nnet3::UnVectorizeNnet(), kaldi::nnet3::UpdateNnetWithMaxChange(), kaldi::nnet3::VectorizeNnet(), and kaldi::nnet3::ZeroComponentStats().
|
inline |
Definition at line 126 of file nnet-nnet.h.
Referenced by ModelCollapser::Collapse(), kaldi::nnet3::computation_graph::ComputeEpochInfo(), ComputationGraphBuilder::ComputeRequiredArray(), kaldi::nnet3::FindOrphanComponents(), kaldi::nnet3::FindOrphanNodes(), SvdApplier::ModifyTopology(), kaldi::nnet3::NnetToDirectedGraph(), kaldi::nnet3::NumInputNodes(), kaldi::nnet3::NumOutputNodes(), ModelCollapser::OptimizeNode(), kaldi::nnet3::ReadEditConfig(), and Nnet::RemoveOrphanComponents().
Definition at line 807 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::component_names_, Nnet::components_, Nnet::Destroy(), rnnlm::i, Nnet::node_names_, and Nnet::nodes_.
int32 OutputDim | ( | const std::string & | output_name | ) | const |
Definition at line 677 of file nnet-nnet.cc.
References NetworkNode::Dim(), and rnnlm::n.
Referenced by BatchedXvectorComputer::BatchedXvectorComputer(), AmNnetSimple::Info(), DecodableNnetSimpleLoopedInfo::Init(), main(), NnetBatchComputer::NnetBatchComputer(), kaldi::nnet3::NnetInfo(), AmNnetSimple::NumPdfs(), AmNnetSimple::SetNnet(), AmNnetSimple::SetPriors(), kaldi::nnet3::TestNnetDecodable(), kaldi::nnet3::UnitTestNnetInputDerivatives(), and kaldi::nnet3::UnitTestNnetModelDerivatives().
|
private |
Definition at line 247 of file nnet-nnet.cc.
References ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), Component::InitFromConfig(), kaldi::IsToken(), KALDI_ERR, Component::NewComponentOfType(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
|
private |
Definition at line 286 of file nnet-nnet.cc.
References NetworkNode::component_index, NetworkNode::descriptor, kaldi::nnet3::DescriptorTokenize(), ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, NetworkNode::NetworkNode(), NetworkNode::node_index, Descriptor::Parse(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
|
private |
Definition at line 420 of file nnet-nnet.cc.
References NetworkNode::dim, NetworkNode::dim_offset, ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, NetworkNode::NetworkNode(), NetworkNode::node_index, NetworkNode::node_type, NetworkNode::u, ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
|
private |
Definition at line 342 of file nnet-nnet.cc.
References NetworkNode::dim, ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kInput, NetworkNode::NetworkNode(), NetworkNode::node_index, ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
|
private |
Definition at line 368 of file nnet-nnet.cc.
References NetworkNode::descriptor, kaldi::nnet3::DescriptorTokenize(), ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kDescriptor, kaldi::nnet3::kLinear, kaldi::nnet3::kQuadratic, NetworkNode::NetworkNode(), NetworkNode::node_index, NetworkNode::objective_type, Descriptor::Parse(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().
void Read | ( | std::istream & | istream, |
bool | binary | ||
) |
Definition at line 586 of file nnet-nnet.cc.
References kaldi::nnet3::ExpectToken(), AmNnetSimple::GetNnet(), KALDI_ASSERT, KALDI_ERR, kaldi::PeekToken(), AmNnetSimple::Read(), TransitionModel::Read(), kaldi::ReadBasicType(), Component::ReadNew(), kaldi::ReadToken(), and Nnet::Swap().
Referenced by AmNnetSimple::Read(), and kaldi::nnet3::UnitTestNnetIo().
void ReadConfig | ( | std::istream & | config_file | ) |
Definition at line 189 of file nnet-nnet.cc.
References rnnlm::i, KALDI_ERR, kaldi::nnet3::ParseConfigLines(), and kaldi::ReadConfigLines().
Referenced by main(), kaldi::nnet3::ModifyNnetIvectorPeriod(), SvdApplier::ModifyTopology(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffine(), kaldi::nnet3::UnitTestConvertRepeatedToBlockAffineComposite(), kaldi::nnet3::UnitTestNnetAnalyze(), kaldi::nnet3::UnitTestNnetCompile(), kaldi::nnet3::UnitTestNnetCompileLooped(), kaldi::nnet3::UnitTestNnetCompileMulti(), kaldi::nnet3::UnitTestNnetCompute(), kaldi::nnet3::UnitTestNnetContext(), kaldi::nnet3::UnitTestNnetInputDerivatives(), kaldi::nnet3::UnitTestNnetIo(), kaldi::nnet3::UnitTestNnetModelDerivatives(), and kaldi::nnet3::UnitTestNnetOptimizeWithOptions().
void RemoveOrphanComponents | ( | ) |
Definition at line 844 of file nnet-nnet.cc.
References Nnet::Check(), Nnet::component_names_, Nnet::components_, kaldi::nnet3::FindOrphanComponents(), rnnlm::i, Nnet::IsComponentNode(), KALDI_ASSERT, KALDI_LOG, rnnlm::n, Nnet::nodes_, and Nnet::NumNodes().
Referenced by ModelCollapser::Collapse(), SvdApplier::ModifyTopology(), and kaldi::nnet3::ReadEditConfig().
void RemoveOrphanNodes | ( | bool | remove_orphan_inputs = false | ) |
Definition at line 932 of file nnet-nnet.cc.
References kaldi::nnet3::FindOrphanNodes(), rnnlm::i, Nnet::IsComponentInputNode(), Nnet::IsInputNode(), KALDI_LOG, and Nnet::RemoveSomeNodes().
Referenced by ModelCollapser::Collapse(), SvdApplier::ModifyTopology(), and kaldi::nnet3::ReadEditConfig().
|
staticprivate |
Definition at line 486 of file nnet-nnet.cc.
References ConfigLine::FirstToken(), ConfigLine::GetValue(), rnnlm::i, kaldi::IsValidName(), KALDI_ASSERT, KALDI_ERR, and ConfigLine::WholeLine().
void RemoveSomeNodes | ( | const std::vector< int32 > & | nodes_to_remove | ) |
Definition at line 881 of file nnet-nnet.cc.
References Nnet::Check(), kaldi::nnet3::DescriptorTokenize(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, rnnlm::n, Nnet::node_names_, and Nnet::nodes_.
Referenced by kaldi::nnet3::ReadEditConfig(), and Nnet::RemoveOrphanNodes().
void ResetGenerators | ( | ) |
Definition at line 951 of file nnet-nnet.cc.
References Nnet::GetComponent(), Nnet::NumComponents(), and RandomComponent::ResetGenerator().
Replace the component indexed by c with a new component.
Frees previous component indexed by c. Takes ownership of the pointer 'component'.
Definition at line 155 of file nnet-nnet.cc.
References KALDI_ASSERT.
Referenced by kaldi::nnet3::ConvertRepeatedToBlockAffine(), and kaldi::nnet3::ReadEditConfig().
void SetNodeName | ( | int32 | node_index, |
const std::string & | new_name | ||
) |
This can be used to modify invidual node names.
Note, this does not affect the neural net structure at all, it just assigns a new name to an existing node while leaving all connections identical.
Definition at line 53 of file nnet-nnet.cc.
References kaldi::IsValidName(), KALDI_ERR, and NetworkNode::node_index.
Referenced by kaldi::nnet3::ReadEditConfig().
void Swap | ( | Nnet * | other | ) |
Definition at line 579 of file nnet-nnet.cc.
References Nnet::component_names_, Nnet::components_, Nnet::node_names_, and Nnet::nodes_.
Referenced by Nnet::Read().
void Write | ( | std::ostream & | ostream, |
bool | binary | ||
) | const |
Definition at line 630 of file nnet-nnet.cc.
References rnnlm::i, KALDI_ASSERT, kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by main(), kaldi::nnet3::UnitTestNnetIo(), and AmNnetSimple::Write().
|
private |
Definition at line 326 of file nnet-nnet.h.
Referenced by Nnet::Info(), Nnet::operator=(), Nnet::RemoveOrphanComponents(), and Nnet::Swap().
|
private |
Definition at line 331 of file nnet-nnet.h.
Referenced by Nnet::Info(), Nnet::Nnet(), Nnet::operator=(), Nnet::RemoveOrphanComponents(), and Nnet::Swap().
|
private |
Definition at line 337 of file nnet-nnet.h.
Referenced by Nnet::operator=(), Nnet::RemoveSomeNodes(), and Nnet::Swap().
|
private |
Definition at line 340 of file nnet-nnet.h.
Referenced by Nnet::operator=(), Nnet::RemoveOrphanComponents(), Nnet::RemoveSomeNodes(), and Nnet::Swap().