OffsetForwardingDescriptor Class Reference

Offsets in 't' and 'x' values of other ForwardingDescriptors. More...

#include <nnet-descriptor.h>

Inheritance diagram for OffsetForwardingDescriptor:
Collaboration diagram for OffsetForwardingDescriptor:

Public Member Functions

virtual Cindex MapToInput (const Index &ind) const
 
virtual int32 Dim (const Nnet &nnet) const
 
virtual ForwardingDescriptorCopy () const
 
virtual void WriteConfig (std::ostream &os, const std::vector< std::string > &node_names) const
 
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 GetNodeDependencies (std::vector< int32 > *node_indexes) const
 This function appends to "node_indexes" all the node indexes. More...
 
virtual BaseFloat GetScaleForNode (int32 node_index) const
 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...
 
 OffsetForwardingDescriptor (ForwardingDescriptor *src, Index offset)
 
virtual ~OffsetForwardingDescriptor ()
 
const ForwardingDescriptorSrc () const
 
- Public Member Functions inherited from ForwardingDescriptor
virtual ~ForwardingDescriptor ()
 
 ForwardingDescriptor ()
 

Private Attributes

ForwardingDescriptorsrc_
 
Index offset_
 

Detailed Description

Offsets in 't' and 'x' values of other ForwardingDescriptors.

Written form is: `Offset(<descriptor>, <t-offset> [, <x-offset> ] )` e.g. `Offset(tdnn2, -2)`

Definition at line 175 of file nnet-descriptor.h.

Constructor & Destructor Documentation

◆ OffsetForwardingDescriptor()

OffsetForwardingDescriptor ( ForwardingDescriptor src,
Index  offset 
)
inline

Definition at line 191 of file nnet-descriptor.h.

◆ ~OffsetForwardingDescriptor()

virtual ~OffsetForwardingDescriptor ( )
inlinevirtual

Definition at line 194 of file nnet-descriptor.h.

194 { delete src_; }

Member Function Documentation

◆ Copy()

ForwardingDescriptor * Copy ( ) const
virtual

Implements ForwardingDescriptor.

Definition at line 129 of file nnet-descriptor.cc.

129  {
131 }
OffsetForwardingDescriptor(ForwardingDescriptor *src, Index offset)
virtual ForwardingDescriptor * Copy() const =0

◆ Dim()

virtual int32 Dim ( const Nnet nnet) const
inlinevirtual

Implements ForwardingDescriptor.

Definition at line 178 of file nnet-descriptor.h.

References ForwardingDescriptor::Copy(), and ForwardingDescriptor::WriteConfig().

178 { return src_->Dim(nnet); }
virtual int32 Dim(const Nnet &nnet) const =0

◆ GetNodeDependencies()

void GetNodeDependencies ( std::vector< int32 > *  node_indexes) const
virtual

This function appends to "node_indexes" all the node indexes.

Implements ForwardingDescriptor.

Definition at line 112 of file nnet-descriptor.cc.

113  {
114  src_->GetNodeDependencies(node_indexes);
115 }
virtual void GetNodeDependencies(std::vector< int32 > *node_indexes) const =0
This function appends to "node_indexes" all the node indexes.

◆ GetScaleForNode()

BaseFloat GetScaleForNode ( int32  node_index) const
virtual

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.

Implements ForwardingDescriptor.

Definition at line 117 of file nnet-descriptor.cc.

117  {
118  return src_->GetScaleForNode(node_index);
119 }
virtual BaseFloat GetScaleForNode(int32 node_index) const =0
This function returns the scale on the node-index &#39;node_index&#39; when it appears in expressions inside ...

◆ MapToInput()

Cindex MapToInput ( const Index ind) const
virtual

Implements ForwardingDescriptor.

Definition at line 122 of file nnet-descriptor.cc.

122  {
123  Index ind_mod(ind);
124  ind_mod += offset_;
125  return src_->MapToInput(ind_mod);
126 }
virtual Cindex MapToInput(const Index &output) const =0

◆ Modulus()

virtual int32 Modulus ( ) const
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 from ForwardingDescriptor.

Definition at line 185 of file nnet-descriptor.h.

References ForwardingDescriptor::GetNodeDependencies(), and ForwardingDescriptor::GetScaleForNode().

185 { return src_->Modulus(); }
virtual int32 Modulus() const
This function is for use in things like clockwork RNNs, where shifting the time of the inputs and out...

◆ Src()

const ForwardingDescriptor& Src ( ) const
inline

Definition at line 199 of file nnet-descriptor.h.

Referenced by ModelCollapser::SumDescriptorIsCollapsible().

199 { return *src_; }

◆ WriteConfig()

void WriteConfig ( std::ostream &  os,
const std::vector< std::string > &  node_names 
) const
virtual

Implements ForwardingDescriptor.

Definition at line 133 of file nnet-descriptor.cc.

References KALDI_ASSERT.

135  {
136  KALDI_ASSERT(offset_.n == 0);
137  os << "Offset(";
138  src_->WriteConfig(os, node_names);
139  os << ", " << offset_.t;
140  if (offset_.x != 0)
141  os << ", " << offset_.x;
142  os << ")";
143 }
virtual void WriteConfig(std::ostream &os, const std::vector< std::string > &node_names) const =0
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

Member Data Documentation

◆ offset_

Index offset_
private

Definition at line 202 of file nnet-descriptor.h.

◆ src_

ForwardingDescriptor* src_
private

Definition at line 201 of file nnet-descriptor.h.


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