A ForwardingDescriptor describes how we copy data from another NetworkNode, or from multiple other NetworkNodes, possibly with a scalar weight. More...
#include <nnet-descriptor.h>
Public Member Functions | |
virtual Cindex | MapToInput (const Index &output) const =0 |
virtual int32 | Dim (const Nnet &nnet) const =0 |
virtual ForwardingDescriptor * | Copy () const =0 |
virtual int32 | Modulus () const |
This function is for use in things like clockwork RNNs, where shifting the time of the inputs and outputs of the network by some multiple integer n would leave things the same, but shifting by non-multiples would change the network structure. More... | |
virtual void | WriteConfig (std::ostream &os, const std::vector< std::string > &node_names) const =0 |
virtual void | GetNodeDependencies (std::vector< int32 > *node_indexes) const =0 |
This function appends to "node_indexes" all the node indexes. More... | |
virtual BaseFloat | GetScaleForNode (int32 node_index) const =0 |
This function returns the scale on the node-index 'node_index' when it appears in expressions inside this descriptor, or +infinity if it does not appear. More... | |
virtual | ~ForwardingDescriptor () |
ForwardingDescriptor () | |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (ForwardingDescriptor) | |
A ForwardingDescriptor describes how we copy data from another NetworkNode, or from multiple other NetworkNodes, possibly with a scalar weight.
In the base case this can just be equivalent to giving the name of another NetworkNode, but we also support things like time-offsets, selecting depending on the index from multiple different inputs, and things like that.
Note: nodes of type kOutput (i.e. output nodes of the network) cannot appear as inputs in any descriptor. This is to simplify compilation.
Definition at line 95 of file nnet-descriptor.h.
|
inlinevirtual |
Definition at line 133 of file nnet-descriptor.h.
|
inline |
Definition at line 134 of file nnet-descriptor.h.
References ForwardingDescriptor::KALDI_DISALLOW_COPY_AND_ASSIGN().
|
pure virtual |
Implemented in ReplaceIndexForwardingDescriptor, RoundingForwardingDescriptor, SwitchingForwardingDescriptor, OffsetForwardingDescriptor, and SimpleForwardingDescriptor.
Referenced by OffsetForwardingDescriptor::Dim(), SwitchingForwardingDescriptor::Dim(), RoundingForwardingDescriptor::Dim(), ReplaceIndexForwardingDescriptor::Dim(), OptionalSumDescriptor::Modulus(), SimpleSumDescriptor::Modulus(), and ConstantSumDescriptor::Modulus().
|
pure virtual |
This function appends to "node_indexes" all the node indexes.
Implemented in ReplaceIndexForwardingDescriptor, RoundingForwardingDescriptor, SwitchingForwardingDescriptor, OffsetForwardingDescriptor, and SimpleForwardingDescriptor.
Referenced by SwitchingForwardingDescriptor::Dim(), ReplaceIndexForwardingDescriptor::Dim(), OptionalSumDescriptor::IsComputable(), ForwardingDescriptor::Modulus(), OffsetForwardingDescriptor::Modulus(), RoundingForwardingDescriptor::Modulus(), and SumDescriptor::~SumDescriptor().
This function returns the scale on the node-index 'node_index' when it appears in expressions inside this descriptor, or +infinity if it does not appear.
E.g. if the descriptor is just `Scale(tdnn2, 2.0)` and the node index for `tdnn2` is 4, then GetScaleForNode(4) would return 2.0. If a particular node_index > 0 appears in different sub-expressions of the descriptor with different scales it is an error (it's not supported) and this function would crash.
Implemented in ReplaceIndexForwardingDescriptor, RoundingForwardingDescriptor, SwitchingForwardingDescriptor, OffsetForwardingDescriptor, and SimpleForwardingDescriptor.
Referenced by SwitchingForwardingDescriptor::Dim(), ReplaceIndexForwardingDescriptor::Dim(), ConstantSumDescriptor::Dim(), OptionalSumDescriptor::IsComputable(), ForwardingDescriptor::Modulus(), OffsetForwardingDescriptor::Modulus(), RoundingForwardingDescriptor::Modulus(), and SumDescriptor::~SumDescriptor().
|
private |
Referenced by ForwardingDescriptor::ForwardingDescriptor(), and GeneralDescriptor::~GeneralDescriptor().
|
inlinevirtual |
This function is for use in things like clockwork RNNs, where shifting the time of the inputs and outputs of the network by some multiple integer n would leave things the same, but shifting by non-multiples would change the network structure.
It returns the smallest modulus to which this descriptor is invariant; the lowest common multiple of all descriptors in the network gives you the modulus for the whole network.
Reimplemented in RoundingForwardingDescriptor, SwitchingForwardingDescriptor, and OffsetForwardingDescriptor.
Definition at line 113 of file nnet-descriptor.h.
References ForwardingDescriptor::GetNodeDependencies(), ForwardingDescriptor::GetScaleForNode(), and ForwardingDescriptor::WriteConfig().
Referenced by SwitchingForwardingDescriptor::Dim(), and SumDescriptor::~SumDescriptor().
|
pure virtual |
Implemented in ReplaceIndexForwardingDescriptor, RoundingForwardingDescriptor, SwitchingForwardingDescriptor, OffsetForwardingDescriptor, and SimpleForwardingDescriptor.
Referenced by OffsetForwardingDescriptor::Dim(), SwitchingForwardingDescriptor::Dim(), RoundingForwardingDescriptor::Dim(), ReplaceIndexForwardingDescriptor::Dim(), ForwardingDescriptor::Modulus(), OptionalSumDescriptor::Modulus(), SimpleSumDescriptor::Modulus(), ConstantSumDescriptor::Modulus(), and SumDescriptor::~SumDescriptor().