StatisticsExtractionComponent Class Reference

#include <nnet-general-component.h>

Inheritance diagram for StatisticsExtractionComponent:
Collaboration diagram for StatisticsExtractionComponent:

Public Member Functions

 StatisticsExtractionComponent ()
 
 StatisticsExtractionComponent (const StatisticsExtractionComponent &other)
 
virtual int32 InputDim () const
 Returns input-dimension of this component. More...
 
virtual int32 OutputDim () const
 Returns output-dimension of this component. More...
 
virtual void InitFromConfig (ConfigLine *cfl)
 Initialize, from a ConfigLine object. More...
 
virtual std::string Type () const
 Returns a string such as "SigmoidComponent", describing the type of the object. More...
 
virtual int32 Properties () const
 Return bitmask of the component's properties. More...
 
virtual void * Propagate (const ComponentPrecomputedIndexes *indexes, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const
 Propagate function. More...
 
virtual void Backprop (const std::string &debug_info, const ComponentPrecomputedIndexes *indexes, const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_value, const CuMatrixBase< BaseFloat > &out_deriv, void *memo, Component *, CuMatrixBase< BaseFloat > *in_deriv) const
 Backprop function; depending on which of the arguments 'to_update' and 'in_deriv' are non-NULL, this can compute input-data derivatives and/or perform model update. More...
 
virtual void Read (std::istream &is, bool binary)
 Read function (used after we know the type of the Component); accepts input that is missing the token that describes the component type, in case it has already been consumed. More...
 
virtual void Write (std::ostream &os, bool binary) const
 Write component to stream. More...
 
virtual ComponentCopy () const
 Copies component (deep copy). More...
 
virtual void GetInputIndexes (const MiscComputationInfo &misc_info, const Index &output_index, std::vector< Index > *desired_indexes) const
 This function only does something interesting for non-simple Components. More...
 
virtual bool IsComputable (const MiscComputationInfo &misc_info, const Index &output_index, const IndexSet &input_index_set, std::vector< Index > *used_inputs) const
 This function only does something interesting for non-simple Components, and it exists to make it possible to manage optionally-required inputs. More...
 
virtual void ReorderIndexes (std::vector< Index > *input_indexes, std::vector< Index > *output_indexes) const
 This function only does something interesting for non-simple Components. More...
 
virtual ComponentPrecomputedIndexesPrecomputeIndexes (const MiscComputationInfo &misc_info, const std::vector< Index > &input_indexes, const std::vector< Index > &output_indexes, bool need_backprop) const
 This function must return NULL for simple Components. More...
 
- Public Member Functions inherited from Component
virtual void StoreStats (const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_value, void *memo)
 This function may store stats on average activation values, and for some component types, the average value of the derivative of the nonlinearity. More...
 
virtual void ZeroStats ()
 Components that provide an implementation of StoreStats should also provide an implementation of ZeroStats(), to set those stats to zero. More...
 
virtual std::string Info () const
 Returns some text-form information about this component, for diagnostics. More...
 
virtual void Scale (BaseFloat scale)
 This virtual function when called on – an UpdatableComponent scales the parameters by "scale" when called by an UpdatableComponent. More...
 
virtual void Add (BaseFloat alpha, const Component &other)
 This virtual function when called by – an UpdatableComponent adds the parameters of another updatable component, times some constant, to the current parameters. More...
 
virtual void DeleteMemo (void *memo) const
 This virtual function only needs to be overwritten by Components that return a non-NULL memo from their Propagate() function. More...
 
virtual void ConsolidateMemory ()
 This virtual function relates to memory management, and avoiding fragmentation. More...
 
 Component ()
 
virtual ~Component ()
 

Private Member Functions

void Check () const
 
StatisticsExtractionComponentoperator= (const StatisticsExtractionComponent &other)
 

Private Attributes

int32 input_dim_
 
int32 input_period_
 
int32 output_period_
 
bool include_variance_
 

Additional Inherited Members

- Static Public Member Functions inherited from Component
static ComponentReadNew (std::istream &is, bool binary)
 Read component from stream (works out its type). Dies on error. More...
 
static ComponentNewComponentOfType (const std::string &type)
 Returns a new Component of the given type e.g. More...
 

Detailed Description

Definition at line 201 of file nnet-general-component.h.

Constructor & Destructor Documentation

◆ StatisticsExtractionComponent() [1/2]

◆ StatisticsExtractionComponent() [2/2]

Member Function Documentation

◆ Backprop()

void Backprop ( const std::string &  debug_info,
const ComponentPrecomputedIndexes indexes,
const CuMatrixBase< BaseFloat > &  in_value,
const CuMatrixBase< BaseFloat > &  out_value,
const CuMatrixBase< BaseFloat > &  out_deriv,
void *  memo,
Component to_update,
CuMatrixBase< BaseFloat > *  in_deriv 
) const
virtual

Backprop function; depending on which of the arguments 'to_update' and 'in_deriv' are non-NULL, this can compute input-data derivatives and/or perform model update.

Parameters
[in]debug_infoThe component name, to be printed out in any warning messages.
[in]indexesA pointer to some information output by this class's PrecomputeIndexes function (will be NULL for simple components, i.e. those that don't do things like splicing).
[in]in_valueThe matrix that was given as input to the Propagate function. Will be ignored (and may be empty) if Properties()&kBackpropNeedsInput == 0.
[in]out_valueThe matrix that was output from the Propagate function. Will be ignored (and may be empty) if Properties()&kBackpropNeedsOutput == 0
[in]out_derivThe derivative at the output of this component.
[in]memoThis will normally be NULL, but for component types that set the flag kUsesMemo, this will be the return value of the Propagate() function that corresponds to this Backprop() function. Ownership of any pointers is not transferred to the Backprop function; DeleteMemo() will be called to delete it.
[out]to_updateIf model update is desired, the Component to be updated, else NULL. Does not have to be identical to this. If supplied, you can assume that to_update->Properties() & kUpdatableComponent is nonzero.
[out]in_derivThe derivative at the input of this component, if needed (else NULL). If Properties()&kBackpropInPlace, may be the same matrix as out_deriv. If Properties()&kBackpropAdds, this is added to by the Backprop routine, else it is set. The component code chooses which mode to work in, based on convenience.

Implements Component.

Definition at line 477 of file nnet-general-component.cc.

References CuMatrixBase< Real >::AddMatMatElements(), CuMatrixBase< Real >::AddRows(), StatisticsExtractionComponentPrecomputedIndexes::backward_indexes, CuMatrixBase< Real >::ColRange(), CuMatrixBase< Real >::CopyRows(), StatisticsExtractionComponent::include_variance_, StatisticsExtractionComponent::input_dim_, KALDI_ASSERT, kaldi::kUndefined, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), NVTX_RANGE, and CuMatrixBase< Real >::SetZero().

485  {
486  NVTX_RANGE("StatisticsExtractionComponent::Backprop");
487  KALDI_ASSERT(indexes_in != NULL);
488  const StatisticsExtractionComponentPrecomputedIndexes *indexes =
489  dynamic_cast<const StatisticsExtractionComponentPrecomputedIndexes*>(indexes_in);
490  in_deriv->SetZero();
491  in_deriv->AddRows(1.0, out_deriv.ColRange(1, input_dim_),
492  indexes->backward_indexes);
493  if (include_variance_) {
494  CuMatrix<BaseFloat> variance_deriv(in_value.NumRows(),
495  in_value.NumCols(),
496  kUndefined);
497  variance_deriv.CopyRows(out_deriv.ColRange(1 + input_dim_, input_dim_),
498  indexes->backward_indexes);
499  in_deriv->AddMatMatElements(2.0, variance_deriv, in_value, 1.0);
500  }
501 }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
#define NVTX_RANGE(name)
Definition: cu-common.h:143

◆ Check()

◆ Copy()

virtual Component* Copy ( ) const
inlinevirtual

◆ GetInputIndexes()

void GetInputIndexes ( const MiscComputationInfo misc_info,
const Index output_index,
std::vector< Index > *  desired_indexes 
) const
virtual

This function only does something interesting for non-simple Components.

For a given index at the output of the component, tells us what indexes are required at its input (note: "required" encompasses also optionally-required things; it will enumerate all things that we'd like to have). See also IsComputable().

Parameters
[in]misc_infoThis argument is supplied to handle things that the framework can't very easily supply: information like which time indexes are needed for AggregateComponent, which time-indexes are available at the input of a recurrent network, and so on. We will add members to misc_info as needed.
[in]output_indexThe Index at the output of the component, for which we are requesting the list of indexes at the component's input.
[out]desired_indexesA list of indexes that are desired at the input. are to be written to here. By "desired" we mean required or optionally-required.

The default implementation of this function is suitable for any SimpleComponent; it just copies the output_index to a single identical element in input_indexes.

Reimplemented from Component.

Definition at line 430 of file nnet-general-component.cc.

References StatisticsExtractionComponent::input_period_, StatisticsExtractionComponent::output_period_, and Index::t.

433  {
434  desired_indexes->clear();
435  Index input_index(output_index);
436  int32 t = output_index.t,
437  t_start = output_period_ * (t / output_period_);
438  if (t_start > t) // could happen for negative t due to
439  t_start -= output_period_; // the way modulus works in C
440  int32 t_end = t_start + output_period_;
441  for (int32 t = t_start; t < t_end; t += input_period_) {
442  input_index.t = t;
443  desired_indexes->push_back(input_index);
444  }
445 }
kaldi::int32 int32

◆ InitFromConfig()

void InitFromConfig ( ConfigLine cfl)
virtual

Initialize, from a ConfigLine object.

Parameters
[in]cflA ConfigLine containing any parameters that are needed for initialization. For example: "dim=100 param-stddev=0.1"

Implements Component.

Definition at line 367 of file nnet-general-component.cc.

References StatisticsExtractionComponent::Check(), ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), StatisticsExtractionComponent::include_variance_, StatisticsExtractionComponent::input_dim_, StatisticsExtractionComponent::input_period_, KALDI_ERR, StatisticsExtractionComponent::output_period_, StatisticsExtractionComponent::Type(), ConfigLine::UnusedValues(), and ConfigLine::WholeLine().

367  {
368  // input-dim is required.
369  bool ok = cfl->GetValue("input-dim", &input_dim_);
370  cfl->GetValue("input-period", &input_period_);
371  cfl->GetValue("output-period", &output_period_);
372  cfl->GetValue("include-variance", &include_variance_);
373  if (cfl->HasUnusedValues())
374  KALDI_ERR << "Could not process these elements in initializer: "
375  << cfl->UnusedValues();
376  if (!ok || input_dim_ <= 0 || input_period_ <= 0 || output_period_ <= 0 ||
377  (output_period_ % input_period_ != 0))
378  KALDI_ERR << "Invalid initializer for layer of type "
379  << Type() << ": \"" << cfl->WholeLine() << "\"";
380  Check();
381 }
#define KALDI_ERR
Definition: kaldi-error.h:147
virtual std::string Type() const
Returns a string such as "SigmoidComponent", describing the type of the object.

◆ InputDim()

virtual int32 InputDim ( ) const
inlinevirtual

Returns input-dimension of this component.

Implements Component.

Definition at line 209 of file nnet-general-component.h.

References DistributeComponent::input_dim_.

◆ IsComputable()

bool IsComputable ( const MiscComputationInfo misc_info,
const Index output_index,
const IndexSet input_index_set,
std::vector< Index > *  used_inputs 
) const
virtual

This function only does something interesting for non-simple Components, and it exists to make it possible to manage optionally-required inputs.

It tells the user whether a given output index is computable from a given set of input indexes, and if so, says which input indexes will be used in the computation.

Implementations of this function are required to have the property that adding an element to "input_index_set" can only ever change IsComputable from false to true, never vice versa.

Parameters
[in]misc_infoSome information specific to the computation, such as minimum and maximum times for certain components to do adaptation on; it's a place to put things that don't easily fit in the framework.
[in]output_indexThe index that is to be computed at the output of this Component.
[in]input_index_setThe set of indexes that is available at the input of this Component.
[out]used_inputsIf this is non-NULL and the output is computable this will be set to the list of input indexes that will actually be used in the computation.
Returns
Returns true iff this output is computable from the provided inputs.

The default implementation of this function is suitable for any SimpleComponent: it just returns true if output_index is in input_index_set, and if so sets used_inputs to vector containing that one Index.

Reimplemented from Component.

Definition at line 398 of file nnet-general-component.cc.

References StatisticsExtractionComponent::input_period_, StatisticsExtractionComponent::output_period_, and Index::t.

402  {
403  Index input_index(output_index);
404  int32 t = output_index.t,
405  t_start = output_period_ * (t / output_period_);
406  if (t_start > t) // could happen for negative t_start due to
407  t_start -= output_period_; // the way modulus works in C.
408  int32 t_end = t_start + output_period_;
409  if (!used_inputs) {
410  for (int32 t = t_start; t < t_end; t += input_period_) {
411  input_index.t = t;
412  if (input_index_set(input_index))
413  return true;
414  }
415  return false;
416  } else {
417  used_inputs->clear();
418  bool ans = false;
419  for (int32 t = t_start; t < t_end; t += input_period_) {
420  input_index.t = t;
421  if (input_index_set(input_index)) {
422  ans = true;
423  used_inputs->push_back(input_index);
424  }
425  }
426  return ans;
427  }
428 }
kaldi::int32 int32

◆ operator=()

StatisticsExtractionComponent& operator= ( const StatisticsExtractionComponent other)
private

◆ OutputDim()

virtual int32 OutputDim ( ) const
inlinevirtual

Returns output-dimension of this component.

Implements Component.

Definition at line 210 of file nnet-general-component.h.

References DistributeComponent::InitFromConfig(), and DistributeComponent::input_dim_.

Referenced by StatisticsExtractionComponent::Propagate().

210  {
211  // count + sum stats [ + sum-squared stats].
212  return 1 + input_dim_ + (include_variance_ ? input_dim_ : 0);
213  }

◆ PrecomputeIndexes()

ComponentPrecomputedIndexes * PrecomputeIndexes ( const MiscComputationInfo misc_info,
const std::vector< Index > &  input_indexes,
const std::vector< Index > &  output_indexes,
bool  need_backprop 
) const
virtual

This function must return NULL for simple Components.

Returns a pointer to a class that may contain some precomputed component-specific and computation-specific indexes to be in used in the Propagate and Backprop functions.

Parameters
[in]misc_infoThis argument is supplied to handle things that the framework can't very easily supply: information like which time indexes are needed for AggregateComponent, which time-indexes are available at the input of a recurrent network, and so on. misc_info may not even ever be used here. We will add members to misc_info as needed.
[in]input_indexesA vector of indexes that explains what time-indexes (and other indexes) each row of the in/in_value/in_deriv matrices given to Propagate and Backprop will mean.
[in]output_indexesA vector of indexes that explains what time-indexes (and other indexes) each row of the out/out_value/out_deriv matrices given to Propagate and Backprop will mean.
[in]need_backpropTrue if we might need to do backprop with this component, so that if any different indexes are needed for backprop then those should be computed too.
Returns
Returns a child-class of class ComponentPrecomputedIndexes, or NULL if this component for does not need to precompute any indexes (e.g. if it is a simple component and does not care about indexes).

Reimplemented from Component.

Definition at line 289 of file nnet-general-component.cc.

References StatisticsExtractionComponentPrecomputedIndexes::backward_indexes, StatisticsExtractionComponentPrecomputedIndexes::counts, Int32Pair::first, StatisticsExtractionComponentPrecomputedIndexes::forward_indexes, rnnlm::i, KALDI_ASSERT, Int32Pair::second, and Index::t.

293  {
294  int32 num_input_indexes = input_indexes.size(),
295  num_output_indexes = output_indexes.size();
296  StatisticsExtractionComponentPrecomputedIndexes *ans = new
297  StatisticsExtractionComponentPrecomputedIndexes();
298  // both input and output indexes are assumed sorted first on
299  // n and x, then on t.
300  Int32Pair invalid_pair;
301  invalid_pair.first = -1;
302  invalid_pair.second = -1;
303  std::vector<Int32Pair> forward_indexes_cpu(output_indexes.size(),
304  invalid_pair);
305  std::vector<int32> backward_indexes_cpu(input_indexes.size(), -1);
306  Vector<BaseFloat> counts_cpu(output_indexes.size());
307 
308  // this map maps from Index to the position in 'input_indexes'.
309  unordered_map<Index, int32, IndexHasher> index_to_input_pos;
310  for (int32 i = 0; i < num_input_indexes; i++)
311  index_to_input_pos[input_indexes[i]] = i;
312 
313  for (int32 i = 0; i < num_output_indexes; i++) {
314  Index output_index = output_indexes[i];
315  Index input_index(output_index);
316  int32 t = output_index.t,
317  t_start = output_period_ * (t / output_period_);
318  if (t_start > t) // could happen for negative t_start due to
319  t_start -= output_period_; // the way modulus works in C.
320  int32 t_end = t_start + output_period_;
321  for (int32 t = t_start; t < t_end; t += input_period_) {
322  input_index.t = t;
323  unordered_map<Index, int32, IndexHasher>::iterator iter =
324  index_to_input_pos.find(input_index);
325  if (iter != index_to_input_pos.end()) {
326  int32 input_pos = iter->second;
327  if (forward_indexes_cpu[i].first == -1) {
328  forward_indexes_cpu[i].first = input_pos;
329  forward_indexes_cpu[i].second = input_pos + 1;
330  counts_cpu(i) = 1.0;
331  } else {
332  // the following might fail, for instance, if the sorting
333  // of the input or output indexes was not as expected.
334  KALDI_ASSERT(forward_indexes_cpu[i].second == input_pos);
335  forward_indexes_cpu[i].second++;
336  counts_cpu(i) += 1.0;
337  }
338  KALDI_ASSERT(backward_indexes_cpu[input_pos] == -1);
339  backward_indexes_cpu[input_pos] = i;
340  }
341  }
342  KALDI_ASSERT(counts_cpu(i) != 0.0);
343  }
344  for (int32 i = 0; i < num_input_indexes; i++) {
345  KALDI_ASSERT(backward_indexes_cpu[i] != -1);
346  }
347  ans->forward_indexes = forward_indexes_cpu;
348  ans->counts = counts_cpu;
349  if (need_backprop)
350  ans->backward_indexes = backward_indexes_cpu;
351  return ans;
352 }
kaldi::int32 int32
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
int32_cuda second
Definition: cu-matrixdim.h:80
int32_cuda first
Definition: cu-matrixdim.h:79

◆ Propagate()

void * Propagate ( const ComponentPrecomputedIndexes indexes,
const CuMatrixBase< BaseFloat > &  in,
CuMatrixBase< BaseFloat > *  out 
) const
virtual

Propagate function.

Parameters
[in]indexesA pointer to some information output by this class's PrecomputeIndexes function (will be NULL for simple components, i.e. those that don't do things like splicing).
[in]inThe input to this component. Num-columns == InputDim().
[out]outThe output of this component. Num-columns == OutputDim(). Note: output of this component will be added to the initial value of "out" if Properties()&kPropagateAdds != 0; otherwise the output will be set and the initial value ignored. Each Component chooses whether it is more convenient implementation-wise to add or set, and the calling code has to deal with it.
Returns
Normally returns NULL, but may return a non-NULL value for components which have the flag kUsesMemo set. This value will be passed into the corresponding Backprop routine.

Implements Component.

Definition at line 448 of file nnet-general-component.cc.

References CuMatrixBase< Real >::ApplyPow(), CuMatrixBase< Real >::ColRange(), CuMatrixBase< Real >::CopyColFromVec(), StatisticsExtractionComponentPrecomputedIndexes::counts, CuArrayBase< T >::Dim(), StatisticsExtractionComponentPrecomputedIndexes::forward_indexes, StatisticsExtractionComponent::include_variance_, StatisticsExtractionComponent::input_dim_, KALDI_ASSERT, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), StatisticsExtractionComponent::OutputDim(), and CuMatrixBase< Real >::SetZero().

451  {
452  KALDI_ASSERT(indexes_in != NULL);
453  const StatisticsExtractionComponentPrecomputedIndexes *indexes =
454  dynamic_cast<const StatisticsExtractionComponentPrecomputedIndexes*>(
455  indexes_in);
456  int32 num_rows_out = out->NumRows();
457  KALDI_ASSERT(indexes != NULL &&
458  indexes->forward_indexes.Dim() == num_rows_out &&
459  in.NumCols() == input_dim_ &&
460  out->NumCols() == OutputDim());
461  out->SetZero();
462  // store the counts.
463  out->CopyColFromVec(indexes->counts, 0);
464  // store the mean stats
465  out->ColRange(1, input_dim_).AddRowRanges(in, indexes->forward_indexes);
466  if (include_variance_) {
467  // store the variance (sum-squared) stats.
468  CuMatrix<BaseFloat> in_squared(in);
469  in_squared.ApplyPow(2.0);
470  out->ColRange(input_dim_ + 1,
471  input_dim_).AddRowRanges(in_squared,
472  indexes->forward_indexes);
473  }
474  return NULL;
475 }
kaldi::int32 int32
virtual int32 OutputDim() const
Returns output-dimension of this component.
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ Properties()

◆ Read()

void Read ( std::istream &  is,
bool  binary 
)
virtual

Read function (used after we know the type of the Component); accepts input that is missing the token that describes the component type, in case it has already been consumed.

Implements Component.

Definition at line 503 of file nnet-general-component.cc.

References StatisticsExtractionComponent::Check(), kaldi::ExpectOneOrTwoTokens(), kaldi::nnet3::ExpectToken(), StatisticsExtractionComponent::include_variance_, StatisticsExtractionComponent::input_dim_, StatisticsExtractionComponent::input_period_, StatisticsExtractionComponent::output_period_, and kaldi::ReadBasicType().

503  {
504  ExpectOneOrTwoTokens(is, binary, "<StatisticsExtractionComponent>",
505  "<InputDim>");
506  ReadBasicType(is, binary, &input_dim_);
507  ExpectToken(is, binary, "<InputPeriod>");
508  ReadBasicType(is, binary, &input_period_);
509  ExpectToken(is, binary, "<OutputPeriod>");
510  ReadBasicType(is, binary, &output_period_);
511  ExpectToken(is, binary, "<IncludeVarinance>");
512  ReadBasicType(is, binary, &include_variance_);
513  ExpectToken(is, binary, "</StatisticsExtractionComponent>");
514  Check();
515 }
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
void ExpectOneOrTwoTokens(std::istream &is, bool binary, const std::string &token1, const std::string &token2)
This function is like ExpectToken but for two tokens, and it will either accept token1 and then token...
Definition: text-utils.cc:536
static void ExpectToken(const std::string &token, const std::string &what_we_are_parsing, const std::string **next_token)

◆ ReorderIndexes()

void ReorderIndexes ( std::vector< Index > *  input_indexes,
std::vector< Index > *  output_indexes 
) const
virtual

This function only does something interesting for non-simple Components.

It provides an opportunity for a Component to reorder the or pad the indexes at its input and output. This might be useful, for instance, if a component requires a particular ordering of the indexes that doesn't correspond to their natural ordering. Components that might modify the indexes are required to return the kReordersIndexes flag in their Properties(). The ReorderIndexes() function is now allowed to insert blanks into the indexes. The 'blanks' must be of the form (n,kNoTime,x), where the marker kNoTime (a very negative number) is there where the 't' indexes normally live. The reason we don't just have, say, (-1,-1,-1), relates to the need to preserve a regular pattern over the 'n' indexes so that 'shortcut compilation' (c.f. ExpandComputation()) can work correctly

Parameters
[in,out]Indexesat the input of the Component.
[in,out]Indexesat the output of the Component

Reimplemented from Component.

Definition at line 389 of file nnet-general-component.cc.

391  {
392  std::sort(input_indexes->begin(), input_indexes->end(),
393  IndexLessNxt());
394  std::sort(output_indexes->begin(), output_indexes->end(),
395  IndexLessNxt());
396 }

◆ Type()

virtual std::string Type ( ) const
inlinevirtual

Returns a string such as "SigmoidComponent", describing the type of the object.

Implements Component.

Definition at line 215 of file nnet-general-component.h.

Referenced by StatisticsExtractionComponent::InitFromConfig(), and StatisticsPoolingComponent::InitFromConfig().

215 { return "StatisticsExtractionComponent"; }

◆ Write()

void Write ( std::ostream &  os,
bool  binary 
) const
virtual

Write component to stream.

Implements Component.

Definition at line 517 of file nnet-general-component.cc.

References StatisticsExtractionComponent::include_variance_, StatisticsExtractionComponent::input_dim_, StatisticsExtractionComponent::input_period_, StatisticsExtractionComponent::output_period_, kaldi::WriteBasicType(), and kaldi::WriteToken().

517  {
518  WriteToken(os, binary, "<StatisticsExtractionComponent>");
519  WriteToken(os, binary, "<InputDim>");
520  WriteBasicType(os, binary, input_dim_);
521  WriteToken(os, binary, "<InputPeriod>");
522  WriteBasicType(os, binary, input_period_);
523  WriteToken(os, binary, "<OutputPeriod>");
524  WriteBasicType(os, binary, output_period_);
525  WriteToken(os, binary, "<IncludeVarinance>");
526  WriteBasicType(os, binary, include_variance_);
527  WriteToken(os, binary, "</StatisticsExtractionComponent>");
528 }
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
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

Member Data Documentation

◆ include_variance_

◆ input_dim_

◆ input_period_

◆ output_period_


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