ReplaceIndexForwardingDescriptor Class Reference

This ForwardingDescriptor modifies the indexes (n, t, x) by replacing one of them (normally t) with a constant value and keeping the rest. More...

#include <nnet-descriptor.h>

Inheritance diagram for ReplaceIndexForwardingDescriptor:
Collaboration diagram for ReplaceIndexForwardingDescriptor:

Public Types

enum  VariableName { kN = 0, kT = 1, kX = 2 }
 

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 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...
 
 ReplaceIndexForwardingDescriptor (ForwardingDescriptor *src, VariableName variable_name, int32 value)
 
virtual ~ReplaceIndexForwardingDescriptor ()
 
- Public Member Functions inherited from ForwardingDescriptor
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 ~ForwardingDescriptor ()
 
 ForwardingDescriptor ()
 

Private Attributes

ForwardingDescriptorsrc_
 
VariableName variable_name_
 
int32 value_
 

Detailed Description

This ForwardingDescriptor modifies the indexes (n, t, x) by replacing one of them (normally t) with a constant value and keeping the rest.

Written form is: `ReplaceIndex(<descriptor>, <variable-name>,

)` e.g. `ReplaceIndex(ivector, t, 0)`

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

Member Enumeration Documentation

◆ VariableName

Constructor & Destructor Documentation

◆ ReplaceIndexForwardingDescriptor()

ReplaceIndexForwardingDescriptor ( ForwardingDescriptor src,
VariableName  variable_name,
int32  value 
)
inline

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

◆ ~ReplaceIndexForwardingDescriptor()

virtual ~ReplaceIndexForwardingDescriptor ( )
inlinevirtual

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

296 { delete src_; }

Member Function Documentation

◆ Copy()

ForwardingDescriptor * Copy ( ) const
virtual

Implements ForwardingDescriptor.

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

237  {
240 
241 }
ReplaceIndexForwardingDescriptor(ForwardingDescriptor *src, VariableName variable_name, int32 value)
virtual ForwardingDescriptor * Copy() const =0

◆ Dim()

virtual int32 Dim ( const Nnet nnet) const
inlinevirtual

◆ 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 215 of file nnet-descriptor.cc.

216  {
217  src_->GetNodeDependencies(node_indexes);
218 }
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 220 of file nnet-descriptor.cc.

221  {
222  return src_->GetScaleForNode(node_index);
223 }
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 225 of file nnet-descriptor.cc.

References KALDI_ERR, Index::t, and Index::x.

225  {
226  Index ind_mod(ind);
227  switch (variable_name_) {
228  case kT: ind_mod.t = value_; break;
229  case kX: ind_mod.x = value_; break;
230  default: // kN or any other value is not allowed (doesn't make sense
231  // to change the minibatch index in this way).
232  KALDI_ERR << "Invalid variable name";
233  }
234  return src_->MapToInput(ind_mod);
235 }
virtual Cindex MapToInput(const Index &output) const =0
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ WriteConfig()

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

Implements ForwardingDescriptor.

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

References KALDI_ASSERT.

245  {
246  os << "ReplaceIndex(";
247  src_->WriteConfig(os, node_names);
249  os << ", " << (variable_name_ == kT ? "t" : "x") << ", "
250  << value_ << ")";
251 }
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

◆ src_

ForwardingDescriptor* src_
private

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

◆ value_

int32 value_
private

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

◆ variable_name_

VariableName variable_name_
private

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


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