All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Component Class Referenceabstract

Abstract class, building block of the network. More...

#include <nnet-component.h>

Inheritance diagram for Component:
Collaboration diagram for Component:

Classes

struct  key_value
 A pair of type and marker,. More...
 

Public Types

enum  ComponentType {
  kUnknown = 0x0, kUpdatableComponent = 0x0100, kAffineTransform, kLinearTransform,
  kConvolutionalComponent, kConvolutional2DComponent, kLstmProjected, kBlstmProjected,
  kRecurrentComponent, kActivationFunction = 0x0200, kSoftmax, kHiddenSoftmax,
  kBlockSoftmax, kSigmoid, kTanh, kParametricRelu,
  kDropout, kLengthNormComponent, kTranform = 0x0400, kRbm,
  kSplice, kCopy, kTranspose, kBlockLinearity,
  kAddShift, kRescale, kKlHmm = 0x0800, kSentenceAveragingComponent,
  kSimpleSentenceAveragingComponent, kAveragePoolingComponent, kAveragePooling2DComponent, kMaxPoolingComponent,
  kMaxPooling2DComponent, kFramePoolingComponent, kParallelComponent, kMultiBasisComponent
}
 Component type identification mechanism,. More...
 

Public Member Functions

 Component (int32 input_dim, int32 output_dim)
 Generic interface of a component,. More...
 
virtual ~Component ()
 
virtual ComponentCopy () const =0
 Copy component (deep copy),. More...
 
virtual ComponentType GetType () const =0
 Get Type Identification of the component,. More...
 
virtual bool IsUpdatable () const
 Check if componeny has 'Updatable' interface (trainable components),. More...
 
virtual bool IsMultistream () const
 Check if component has 'Recurrent' interface (trainable and recurrent),. More...
 
int32 InputDim () const
 Get the dimension of the input,. More...
 
int32 OutputDim () const
 Get the dimension of the output,. More...
 
void Propagate (const CuMatrixBase< BaseFloat > &in, CuMatrix< BaseFloat > *out)
 Perform forward-pass propagation 'in' -> 'out',. More...
 
void Backpropagate (const CuMatrixBase< BaseFloat > &in, const CuMatrixBase< BaseFloat > &out, const CuMatrixBase< BaseFloat > &out_diff, CuMatrix< BaseFloat > *in_diff)
 Perform backward-pass propagation 'out_diff' -> 'in_diff'. More...
 
void Write (std::ostream &os, bool binary) const
 Write the component to a stream,. More...
 
virtual std::string Info () const
 Print some additional info (after <ComponentName> and the dims),. More...
 
virtual std::string InfoGradient () const
 Print some additional info about gradient (after <...> and dims),. More...
 

Static Public Member Functions

static const char * TypeToMarker (ComponentType t)
 Converts component type to marker,. More...
 
static ComponentType MarkerToType (const std::string &s)
 Converts marker to component type (case insensitive),. More...
 
static ComponentInit (const std::string &conf_line)
 Initialize component from a line in config file,. More...
 
static ComponentRead (std::istream &is, bool binary)
 Read the component from a stream (static method),. More...
 

Static Public Attributes

static const struct key_value kMarkerMap []
 The table with pairs of Component types and markers (defined in nnet-component.cc),. More...
 

Protected Member Functions

virtual void PropagateFnc (const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)=0
 Abstract interface for propagation/backpropagation. More...
 
virtual void BackpropagateFnc (const CuMatrixBase< BaseFloat > &in, const CuMatrixBase< BaseFloat > &out, const CuMatrixBase< BaseFloat > &out_diff, CuMatrixBase< BaseFloat > *in_diff)=0
 Backward pass transformation (to be implemented by descending class...) More...
 
virtual void InitData (std::istream &is)
 Virtual interface for initialization and I/O,. More...
 
virtual void ReadData (std::istream &is, bool binary)
 Reads the component content. More...
 
virtual void WriteData (std::ostream &os, bool binary) const
 Writes the component content. More...
 

Protected Attributes

int32 input_dim_
 Data members,. More...
 
int32 output_dim_
 Dimension of the output of the Component,. More...
 

Static Private Member Functions

static ComponentNewComponentOfType (ComponentType t, int32 input_dim, int32 output_dim)
 Private members (descending classes cannot call this),. More...
 

Detailed Description

Abstract class, building block of the network.

It is able to propagate (PropagateFnc: compute the output based on its input) and backpropagate (BackpropagateFnc: i.e. transform loss derivative w.r.t. output to derivative w.r.t. the input) the formulas are implemented in descendant classes (AffineTransform,Sigmoid,Softmax,...).

Definition at line 55 of file nnet-component.cc.

Member Enumeration Documentation

Component type identification mechanism,.

Types of Components,

Enumerator
kUnknown 
kUpdatableComponent 
kAffineTransform 
kLinearTransform 
kConvolutionalComponent 
kConvolutional2DComponent 
kLstmProjected 
kBlstmProjected 
kRecurrentComponent 
kActivationFunction 
kSoftmax 
kHiddenSoftmax 
kBlockSoftmax 
kSigmoid 
kTanh 
kParametricRelu 
kDropout 
kLengthNormComponent 
kTranform 
kRbm 
kSplice 
kCopy 
kTranspose 
kBlockLinearity 
kAddShift 
kRescale 
kKlHmm 
kSentenceAveragingComponent 
kSimpleSentenceAveragingComponent 
kAveragePoolingComponent 
kAveragePooling2DComponent 
kMaxPoolingComponent 
kMaxPooling2DComponent 
kFramePoolingComponent 
kParallelComponent 
kMultiBasisComponent 

Definition at line 47 of file nnet-component.h.

47  {
48  kUnknown = 0x0,
49 
50  kUpdatableComponent = 0x0100,
58 
59  kActivationFunction = 0x0200,
60  kSoftmax,
63  kSigmoid,
64  kTanh,
66  kDropout,
68 
69  kTranform = 0x0400,
70  kRbm,
71  kSplice,
72  kCopy,
73  kTranspose,
75  kAddShift,
76  kRescale,
77 
78  kKlHmm = 0x0800,
79  kSentenceAveragingComponent, /* deprecated */
88  } ComponentType;
ComponentType
Component type identification mechanism,.

Constructor & Destructor Documentation

Component ( int32  input_dim,
int32  output_dim 
)
inline

Generic interface of a component,.

Definition at line 108 of file nnet-component.h.

108  :
109  input_dim_(input_dim),
110  output_dim_(output_dim)
111  { }
int32 input_dim_
Data members,.
int32 output_dim_
Dimension of the output of the Component,.
virtual ~Component ( )
inlinevirtual

Definition at line 113 of file nnet-component.h.

114  { }

Member Function Documentation

void Backpropagate ( const CuMatrixBase< BaseFloat > &  in,
const CuMatrixBase< BaseFloat > &  out,
const CuMatrixBase< BaseFloat > &  out_diff,
CuMatrix< BaseFloat > *  in_diff 
)
inline

Perform backward-pass propagation 'out_diff' -> 'in_diff'.

Note: 'in' and 'out' will be used only sometimes...

Definition at line 328 of file nnet-component.h.

References Component::BackpropagateFnc(), Component::InputDim(), KALDI_ASSERT, KALDI_ERR, kaldi::kSetZero, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), Component::OutputDim(), and CuMatrix< Real >::Resize().

Referenced by kaldi::nnet1::UnitTestAveragePooling2DComponent(), kaldi::nnet1::UnitTestConvolutional2DComponent(), kaldi::nnet1::UnitTestConvolutionalComponent3x3(), kaldi::nnet1::UnitTestConvolutionalComponentUnity(), kaldi::nnet1::UnitTestDropoutComponent(), kaldi::nnet1::UnitTestMaxPooling2DComponent(), kaldi::nnet1::UnitTestMaxPoolingComponent(), and kaldi::nnet1::UnitTestSimpleSentenceAveragingComponent().

331  {
332  // Check the dims,
333  if (OutputDim() != out_diff.NumCols()) {
334  KALDI_ERR << "Non-matching dims! Component output dim " << OutputDim()
335  << ", the dim of output derivatives " << out_diff.NumCols();
336  }
337 
338  int32 num_frames = out_diff.NumRows();
339  KALDI_ASSERT(num_frames == in.NumRows());
340  KALDI_ASSERT(num_frames == out.NumRows());
341 
342  KALDI_ASSERT(InputDim() == in.NumCols());
343  KALDI_ASSERT(OutputDim() == out.NumCols());
344 
345  // Allocate target buffer,
346  KALDI_ASSERT(in_diff != NULL);
347  in_diff->Resize(num_frames, InputDim(), kSetZero); // reset,
348 
349  // Call the 'virtual' backprop function,
350  BackpropagateFnc(in, out, out_diff, in_diff);
351 }
int32 OutputDim() const
Get the dimension of the output,.
MatrixIndexT NumCols() const
Definition: cu-matrix.h:201
void Resize(MatrixIndexT rows, MatrixIndexT cols, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Allocate the memory.
Definition: cu-matrix.cc:47
MatrixIndexT NumRows() const
Dimensions.
Definition: cu-matrix.h:200
#define KALDI_ERR
Definition: kaldi-error.h:127
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
int32 InputDim() const
Get the dimension of the input,.
virtual void BackpropagateFnc(const CuMatrixBase< BaseFloat > &in, const CuMatrixBase< BaseFloat > &out, const CuMatrixBase< BaseFloat > &out_diff, CuMatrixBase< BaseFloat > *in_diff)=0
Backward pass transformation (to be implemented by descending class...)
virtual std::string Info ( ) const
inlinevirtual
virtual std::string InfoGradient ( ) const
inlinevirtual
Component * Init ( const std::string &  conf_line)
static

Initialize component from a line in config file,.

Definition at line 219 of file nnet-component.cc.

References kaldi::ExpectToken(), Component::InitData(), Component::MarkerToType(), Component::NewComponentOfType(), kaldi::ReadBasicType(), and kaldi::ReadToken().

Referenced by Nnet::Init(), kaldi::nnet1::UnitTestAveragePooling2DComponent(), kaldi::nnet1::UnitTestMaxPooling2DComponent(), and kaldi::nnet1::UnitTestMaxPoolingComponent().

219  {
220  std::istringstream is(conf_line);
221  std::string component_type_string;
222  int32 input_dim, output_dim;
223 
224  // initialize component w/o internal data
225  ReadToken(is, false, &component_type_string);
226  ComponentType component_type = MarkerToType(component_type_string);
227  ExpectToken(is, false, "<InputDim>");
228  ReadBasicType(is, false, &input_dim);
229  ExpectToken(is, false, "<OutputDim>");
230  ReadBasicType(is, false, &output_dim);
231  Component *ans = NewComponentOfType(component_type, input_dim, output_dim);
232 
233  // initialize internal data with the remaining part of config line
234  ans->InitData(is);
235 
236  return ans;
237 }
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
Component(int32 input_dim, int32 output_dim)
Generic interface of a component,.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
Definition: io-funcs.cc:154
ComponentType
Component type identification mechanism,.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:188
static ComponentType MarkerToType(const std::string &s)
Converts marker to component type (case insensitive),.
static Component * NewComponentOfType(ComponentType t, int32 input_dim, int32 output_dim)
Private members (descending classes cannot call this),.
virtual bool IsMultistream ( ) const
inlinevirtual

Check if component has 'Recurrent' interface (trainable and recurrent),.

Reimplemented in MultistreamComponent.

Definition at line 128 of file nnet-component.h.

Referenced by Nnet::ResetStreams(), and Nnet::SetSeqLengths().

128  {
129  return false;
130  }
virtual bool IsUpdatable ( ) const
inlinevirtual

Check if componeny has 'Updatable' interface (trainable components),.

Reimplemented in UpdatableComponent.

Definition at line 123 of file nnet-component.h.

Referenced by main(), and Nnet::SetTrainOptions().

123  {
124  return false;
125  }
Component::ComponentType MarkerToType ( const std::string &  s)
static

Converts marker to component type (case insensitive),.

Definition at line 101 of file nnet-component.cc.

References rnnlm::i, KALDI_ERR, Component::kMarkerMap, and Component::kUnknown.

Referenced by Component::Init(), and Component::Read().

101  {
102  std::string s_lowercase(s);
103  std::transform(s.begin(), s.end(), s_lowercase.begin(), ::tolower); // lc
104  int32 N = sizeof(kMarkerMap) / sizeof(kMarkerMap[0]);
105  for (int i = 0; i < N; i++) {
106  std::string m(kMarkerMap[i].value);
107  std::string m_lowercase(m);
108  std::transform(m.begin(), m.end(), m_lowercase.begin(), ::tolower);
109  if (s_lowercase == m_lowercase) return kMarkerMap[i].key;
110  }
111  KALDI_ERR << "Unknown 'Component' marker : '" << s << "'\n"
112  << "(isn't the model 'too old' or incompatible?)";
113  return kUnknown;
114 }
static const struct key_value kMarkerMap[]
The table with pairs of Component types and markers (defined in nnet-component.cc),.
#define KALDI_ERR
Definition: kaldi-error.h:127
Component * NewComponentOfType ( ComponentType  t,
int32  input_dim,
int32  output_dim 
)
staticprivate

Private members (descending classes cannot call this),.

Create a new intance of component,

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

References Component::kAddShift, Component::kAffineTransform, KALDI_ERR, Component::kAveragePooling2DComponent, Component::kAveragePoolingComponent, Component::kBlockSoftmax, Component::kBlstmProjected, Component::kConvolutional2DComponent, Component::kConvolutionalComponent, Component::kCopy, Component::kDropout, Component::kFramePoolingComponent, Component::kHiddenSoftmax, Component::kKlHmm, Component::kLengthNormComponent, Component::kLinearTransform, Component::kLstmProjected, Component::kMaxPooling2DComponent, Component::kMaxPoolingComponent, Component::kMultiBasisComponent, Component::kParallelComponent, Component::kParametricRelu, Component::kRbm, Component::kRecurrentComponent, Component::kRescale, Component::kSentenceAveragingComponent, Component::kSigmoid, Component::kSimpleSentenceAveragingComponent, Component::kSoftmax, Component::kSplice, Component::kTanh, Component::kUnknown, kaldi::cu::Splice(), and Component::TypeToMarker().

Referenced by Component::Init(), and Component::Read().

118  {
119  Component *ans = NULL;
120  switch (comp_type) {
122  ans = new AffineTransform(input_dim, output_dim);
123  break;
125  ans = new LinearTransform(input_dim, output_dim);
126  break;
128  ans = new ConvolutionalComponent(input_dim, output_dim);
129  break;
131  ans = new Convolutional2DComponent(input_dim, output_dim);
132  break;
134  ans = new LstmProjected(input_dim, output_dim);
135  break;
137  ans = new BlstmProjected(input_dim, output_dim);
138  break;
140  ans = new RecurrentComponent(input_dim, output_dim);
141  break;
142  case Component::kSoftmax :
143  ans = new Softmax(input_dim, output_dim);
144  break;
146  ans = new HiddenSoftmax(input_dim, output_dim);
147  break;
149  ans = new BlockSoftmax(input_dim, output_dim);
150  break;
151  case Component::kSigmoid :
152  ans = new Sigmoid(input_dim, output_dim);
153  break;
154  case Component::kTanh :
155  ans = new Tanh(input_dim, output_dim);
156  break;
158  ans = new ParametricRelu(input_dim, output_dim);
159  break;
160  case Component::kDropout :
161  ans = new Dropout(input_dim, output_dim);
162  break;
164  ans = new LengthNormComponent(input_dim, output_dim);
165  break;
166  case Component::kRbm :
167  ans = new Rbm(input_dim, output_dim);
168  break;
169  case Component::kSplice :
170  ans = new Splice(input_dim, output_dim);
171  break;
172  case Component::kCopy :
173  ans = new CopyComponent(input_dim, output_dim);
174  break;
175  case Component::kAddShift :
176  ans = new AddShift(input_dim, output_dim);
177  break;
178  case Component::kRescale :
179  ans = new Rescale(input_dim, output_dim);
180  break;
181  case Component::kKlHmm :
182  ans = new KlHmm(input_dim, output_dim);
183  break;
185  ans = new SentenceAveragingComponent(input_dim, output_dim);
186  break;
188  ans = new SimpleSentenceAveragingComponent(input_dim, output_dim);
189  break;
191  ans = new AveragePoolingComponent(input_dim, output_dim);
192  break;
194  ans = new AveragePooling2DComponent(input_dim, output_dim);
195  break;
197  ans = new MaxPoolingComponent(input_dim, output_dim);
198  break;
200  ans = new MaxPooling2DComponent(input_dim, output_dim);
201  break;
203  ans = new FramePoolingComponent(input_dim, output_dim);
204  break;
206  ans = new ParallelComponent(input_dim, output_dim);
207  break;
209  ans = new MultiBasisComponent(input_dim, output_dim);
210  break;
211  case Component::kUnknown :
212  default :
213  KALDI_ERR << "Missing type: " << TypeToMarker(comp_type);
214  }
215  return ans;
216 }
Component(int32 input_dim, int32 output_dim)
Generic interface of a component,.
static const char * TypeToMarker(ComponentType t)
Converts component type to marker,.
#define KALDI_ERR
Definition: kaldi-error.h:127
void Splice(const CuMatrixBase< Real > &src, const CuArray< int32 > &frame_offsets, CuMatrixBase< Real > *tgt)
Splice concatenates frames of src as specified in frame_offsets into tgt.
Definition: cu-math.cc:132
void Propagate ( const CuMatrixBase< BaseFloat > &  in,
CuMatrix< BaseFloat > *  out 
)
inline

Perform forward-pass propagation 'in' -> 'out',.

Definition at line 314 of file nnet-component.h.

References Component::GetType(), Component::input_dim_, KALDI_ERR, kaldi::kSetZero, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), Component::output_dim_, Component::PropagateFnc(), CuMatrix< Real >::Resize(), and Component::TypeToMarker().

Referenced by kaldi::nnet1::UnitTestAveragePooling2DComponent(), kaldi::nnet1::UnitTestConvolutional2DComponent(), kaldi::nnet1::UnitTestConvolutionalComponent3x3(), kaldi::nnet1::UnitTestConvolutionalComponentUnity(), kaldi::nnet1::UnitTestDropoutComponent(), kaldi::nnet1::UnitTestLengthNorm(), kaldi::nnet1::UnitTestMaxPooling2DComponent(), kaldi::nnet1::UnitTestMaxPoolingComponent(), and kaldi::nnet1::UnitTestSimpleSentenceAveragingComponent().

315  {
316  // Check the dims
317  if (input_dim_ != in.NumCols()) {
318  KALDI_ERR << "Non-matching dims on the input of " << TypeToMarker(GetType())
319  << " component. The input-dim is " << input_dim_
320  << ", the data had " << in.NumCols() << " dims.";
321  }
322  // Allocate target buffer
323  out->Resize(in.NumRows(), output_dim_, kSetZero); // reset
324  // Call the propagation implementation of the component
325  PropagateFnc(in, out);
326 }
int32 input_dim_
Data members,.
MatrixIndexT NumCols() const
Definition: cu-matrix.h:201
static const char * TypeToMarker(ComponentType t)
Converts component type to marker,.
void Resize(MatrixIndexT rows, MatrixIndexT cols, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Allocate the memory.
Definition: cu-matrix.cc:47
MatrixIndexT NumRows() const
Dimensions.
Definition: cu-matrix.h:200
#define KALDI_ERR
Definition: kaldi-error.h:127
int32 output_dim_
Dimension of the output of the Component,.
virtual void PropagateFnc(const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out)=0
Abstract interface for propagation/backpropagation.
virtual ComponentType GetType() const =0
Get Type Identification of the component,.
Component * Read ( std::istream &  is,
bool  binary 
)
static

Read the component from a stream (static method),.

Definition at line 240 of file nnet-component.cc.

References kaldi::ExpectToken(), Component::MarkerToType(), Component::NewComponentOfType(), kaldi::Peek(), kaldi::PeekToken(), kaldi::ReadBasicType(), Component::ReadData(), and kaldi::ReadToken().

Referenced by Nnet::Read(), and kaldi::nnet1::ReadComponentFromString().

240  {
241  int32 dim_out, dim_in;
242  std::string token;
243 
244  int first_char = Peek(is, binary);
245  if (first_char == EOF) return NULL;
246 
247  ReadToken(is, binary, &token);
248  // Skip the optional initial token,
249  if (token == "<Nnet>") {
250  ReadToken(is, binary, &token);
251  }
252  // Network ends after terminal token appears,
253  if (token == "</Nnet>") {
254  return NULL;
255  }
256 
257  // Read the dims,
258  ReadBasicType(is, binary, &dim_out);
259  ReadBasicType(is, binary, &dim_in);
260 
261  // Create the component,
262  Component *ans = NewComponentOfType(MarkerToType(token), dim_in, dim_out);
263 
264  // Read the content,
265  ans->ReadData(is, binary);
266 
267  // 'Eat' the component separtor (can be already consumed by 'ReadData(.)'),
268  if ('<' == Peek(is, binary) && '!' == PeekToken(is, binary)) {
269  ExpectToken(is, binary, "<!EndOfComponent>");
270  }
271 
272  return ans;
273 }
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
Component(int32 input_dim, int32 output_dim)
Generic interface of a component,.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
Definition: io-funcs.cc:154
int Peek(std::istream &is, bool binary)
Peek consumes whitespace (if binary == false) and then returns the peek() value of the stream...
Definition: io-funcs.cc:145
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:188
static ComponentType MarkerToType(const std::string &s)
Converts marker to component type (case insensitive),.
int PeekToken(std::istream &is, bool binary)
PeekToken will return the first character of the next token, or -1 if end of file.
Definition: io-funcs.cc:170
static Component * NewComponentOfType(ComponentType t, int32 input_dim, int32 output_dim)
Private members (descending classes cannot call this),.
const char * TypeToMarker ( ComponentType  t)
static

Converts component type to marker,.

Definition at line 91 of file nnet-component.cc.

References rnnlm::i, KALDI_ERR, and Component::kMarkerMap.

Referenced by CopyComponent::BackpropagateFnc(), Nnet::Check(), kaldi::ConvertComponent(), Nnet::Info(), Nnet::InfoBackPropagate(), Nnet::InfoGradient(), Nnet::InfoPropagate(), main(), Component::NewComponentOfType(), Component::Propagate(), Component::Write(), and Rbm::WriteAsNnet().

91  {
92  // Retuns the 1st '<string>' corresponding to the type in 'kMarkerMap',
93  int32 N = sizeof(kMarkerMap) / sizeof(kMarkerMap[0]);
94  for (int i = 0; i < N; i++) {
95  if (kMarkerMap[i].key == t) return kMarkerMap[i].value;
96  }
97  KALDI_ERR << "Unknown type : " << t;
98  return NULL;
99 }
static const struct key_value kMarkerMap[]
The table with pairs of Component types and markers (defined in nnet-component.cc),.
#define KALDI_ERR
Definition: kaldi-error.h:127
void Write ( std::ostream &  os,
bool  binary 
) const

Write the component to a stream,.

Definition at line 276 of file nnet-component.cc.

References Component::GetType(), Component::InputDim(), Component::OutputDim(), Component::TypeToMarker(), kaldi::WriteBasicType(), Component::WriteData(), and kaldi::WriteToken().

Referenced by main().

276  {
278  WriteBasicType(os, binary, OutputDim());
279  WriteBasicType(os, binary, InputDim());
280  if (!binary) os << "\n";
281  this->WriteData(os, binary);
282  WriteToken(os, binary, "<!EndOfComponent>"); // Write component separator.
283  if (!binary) os << "\n";
284 }
int32 OutputDim() const
Get the dimension of the output,.
static const char * TypeToMarker(ComponentType t)
Converts component type to marker,.
virtual void WriteData(std::ostream &os, bool binary) const
Writes the component content.
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
virtual ComponentType GetType() const =0
Get Type Identification of the component,.
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:34
int32 InputDim() const
Get the dimension of the input,.

Member Data Documentation

const struct key_value kMarkerMap[]
static

The table with pairs of Component types and markers (defined in nnet-component.cc),.

Definition at line 98 of file nnet-component.h.

Referenced by Component::MarkerToType(), and Component::TypeToMarker().


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