NetworkNode Struct Reference

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

#include <nnet-nnet.h>

Collaboration diagram for NetworkNode:

Public Member Functions

int32 Dim (const Nnet &nnet) const
 NetworkNode (NodeType nt=kNone)
 NetworkNode (const NetworkNode &other)

Public Attributes

NodeType node_type
Descriptor descriptor
union {
   int32   component_index
   int32   node_index
   ObjectiveType   objective_type
int32 dim
int32 dim_offset

Detailed Description

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.

an affine component or a sigmoid component); or a Descriptor. A Descriptor is basically an expression that can do things like append the outputs of other components (or inputs) together, add them together, and do various other things like shifting the time index.

Each Component must have an input of type kDescriptor that is numbered Preceding to the Component, and that is not used elsewhere. This may seem unintuitive but it makes the implementation a lot easier; any apparent waste can be optimized out after compilation. And outputs must also be of type kDescriptor.

Note: in the actual computation you can provide input not only to nodes of type kInput but also to nodes of type kComponent; this is useful in things like recurrent nets where you may want to split the computation up into pieces.

Note that in the config-file format, there are three types of node: input, component and output. output maps to kDescriptor, but the nodes of type kDescriptor that represent the input to a component, are described in the same config-file line as the Component itself.

Definition at line 81 of file nnet-nnet.h.

Constructor & Destructor Documentation

◆ NetworkNode() [1/2]

NetworkNode ( NodeType  nt = kNone)

Definition at line 107 of file nnet-nnet.h.

References NetworkNode::u.

Referenced by Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessDimRangeNodeConfigLine(), Nnet::ProcessInputNodeConfigLine(), and Nnet::ProcessOutputNodeConfigLine().

107  :
108  node_type(nt), dim(-1), dim_offset(-1) { u.component_index = -1; }
union kaldi::nnet3::NetworkNode::@15 u

◆ NetworkNode() [2/2]

NetworkNode ( const NetworkNode other)

Definition at line 545 of file

References NetworkNode::component_index, and NetworkNode::u.

545  :
546  node_type(other.node_type),
547  descriptor(other.descriptor),
548  dim(other.dim),
549  dim_offset(other.dim_offset) {
550  u.component_index = other.u.component_index;
551 }
union kaldi::nnet3::NetworkNode::@15 u

Member Function Documentation

◆ Dim()

int32 Dim ( const Nnet nnet) const

Definition at line 33 of file

References NetworkNode::descriptor, NetworkNode::dim, Descriptor::Dim(), Nnet::GetComponent(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, NetworkNode::node_type, Component::OutputDim(), and NetworkNode::u.

Referenced by Nnet::Check(), Compiler::CreateStepInfo(), SimpleForwardingDescriptor::Dim(), and Nnet::OutputDim().

33  {
34  int32 ans;
35  switch (node_type) {
36  case kInput: case kDimRange:
37  ans = dim;
38  break;
39  case kDescriptor:
40  ans = descriptor.Dim(nnet);
41  break;
42  case kComponent:
43  ans = nnet.GetComponent(u.component_index)->OutputDim();
44  break;
45  default:
46  ans = 0; // suppress compiler warning
47  KALDI_ERR << "Invalid node type.";
48  }
49  KALDI_ASSERT(ans > 0);
50  return ans;
51 }
kaldi::int32 int32
#define KALDI_ERR
Definition: kaldi-error.h:147
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
union kaldi::nnet3::NetworkNode::@15 u
int32 Dim(const Nnet &nnet) const

Member Data Documentation

◆ component_index

◆ descriptor

◆ dim

◆ dim_offset

◆ node_index

◆ node_type

◆ objective_type

◆ u

The documentation for this struct was generated from the following files: