This kind of Component is a base-class for things like sigmoid and softmax. More...
#include <nnet-component.h>
Public Member Functions | |
void | Init (int32 dim) |
NonlinearComponent (int32 dim) | |
NonlinearComponent () | |
NonlinearComponent (const NonlinearComponent &other) | |
virtual int32 | InputDim () const |
Get size of input vectors. More... | |
virtual int32 | OutputDim () const |
Get size of output vectors. More... | |
virtual void | InitFromString (std::string args) |
We implement InitFromString at this level. More... | |
virtual void | Read (std::istream &is, bool binary) |
We implement Read at this level as it just needs the Type(). More... | |
virtual void | Write (std::ostream &os, bool binary) const |
Write component to stream. More... | |
void | Scale (BaseFloat scale) |
void | Add (BaseFloat alpha, const NonlinearComponent &other) |
const CuVector< double > & | ValueSum () const |
const CuVector< double > & | DerivSum () const |
double | Count () const |
void | SetDim (int32 dim) |
Public Member Functions inherited from Component | |
Component () | |
virtual std::string | Type () const =0 |
virtual int32 | Index () const |
Returns the index in the sequence of layers in the neural net; intended only to be used in debugging information. More... | |
virtual void | SetIndex (int32 index) |
virtual std::vector< int32 > | Context () const |
Return a vector describing the temporal context this component requires for each frame of output, as a sorted list. More... | |
virtual void | Propagate (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const =0 |
Perform forward pass propagation Input->Output. More... | |
void | Propagate (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrix< BaseFloat > *out) const |
A non-virtual propagate function that first resizes output if necessary. More... | |
virtual void | Backprop (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_value, const CuMatrixBase< BaseFloat > &out_deriv, Component *to_update, CuMatrix< BaseFloat > *in_deriv) const =0 |
Perform backward pass propagation of the derivative, and also either update the model (if to_update == this) or update another model or compute the model derivative (otherwise). More... | |
virtual bool | BackpropNeedsInput () const |
virtual bool | BackpropNeedsOutput () const |
virtual Component * | Copy () const =0 |
Copy component (deep copy). More... | |
virtual std::string | Info () const |
virtual | ~Component () |
Protected Member Functions | |
void | UpdateStats (const CuMatrixBase< BaseFloat > &out_value, const CuMatrixBase< BaseFloat > *deriv=NULL) |
const NonlinearComponent & | operator= (const NonlinearComponent &other) |
Protected Attributes | |
int32 | dim_ |
CuVector< double > | value_sum_ |
CuVector< double > | deriv_sum_ |
double | count_ |
std::mutex | mutex_ |
Friends | |
class | NormalizationComponent |
class | SigmoidComponent |
class | TanhComponent |
class | SoftmaxComponent |
class | LogSoftmaxComponent |
class | RectifiedLinearComponent |
class | SoftHingeComponent |
Additional Inherited Members | |
Static Public Member Functions inherited from Component | |
static Component * | ReadNew (std::istream &is, bool binary) |
Read component from stream. More... | |
static Component * | NewFromString (const std::string &initializer_line) |
Initialize the Component from one line that will contain first the type, e.g. More... | |
static Component * | NewComponentOfType (const std::string &type) |
Return a new Component of the given type e.g. More... | |
This kind of Component is a base-class for things like sigmoid and softmax.
Definition at line 352 of file nnet-component.h.
|
inlineexplicit |
Definition at line 355 of file nnet-component.h.
|
inline |
Definition at line 356 of file nnet-component.h.
|
explicit |
Definition at line 405 of file nnet-component.cc.
void Add | ( | BaseFloat | alpha, |
const NonlinearComponent & | other | ||
) |
Definition at line 362 of file nnet-component.cc.
References NonlinearComponent::count_, NonlinearComponent::deriv_sum_, CuVectorBase< Real >::Dim(), and NonlinearComponent::value_sum_.
Referenced by Nnet::AddNnet(), Nnet::CopyStatsFrom(), and main().
|
inline |
Definition at line 379 of file nnet-component.h.
Referenced by NnetStats::AddStatsFromNnet(), and kaldi::nnet2::FixNnet().
|
inline |
Definition at line 378 of file nnet-component.h.
Referenced by NnetStats::AddStatsFromNnet(), and kaldi::nnet2::FixNnet().
|
inline |
Definition at line 354 of file nnet-component.h.
Referenced by NonlinearComponent::InitFromString(), MaxoutComponent::InitFromString(), PnormComponent::InitFromString(), PowerComponent::InitFromString(), and ScaleComponent::InitFromString().
|
virtual |
We implement InitFromString at this level.
Implements Component.
Reimplemented in PowerComponent.
Definition at line 409 of file nnet-component.cc.
References NonlinearComponent::Init(), KALDI_ERR, kaldi::nnet2::ParseFromString(), and Component::Type().
Referenced by kaldi::nnet2::UnitTestSigmoidComponent().
|
inlinevirtual |
Get size of input vectors.
Implements Component.
Reimplemented in PowerComponent.
Definition at line 359 of file nnet-component.h.
Referenced by kaldi::nnet2::FixNnet().
|
protected |
|
inlinevirtual |
Get size of output vectors.
Implements Component.
Reimplemented in PowerComponent.
Definition at line 360 of file nnet-component.h.
|
virtual |
We implement Read at this level as it just needs the Type().
Implements Component.
Reimplemented in PowerComponent.
Definition at line 374 of file nnet-component.cc.
References kaldi::nnet2::ExpectOneOrTwoTokens(), kaldi::ExpectToken(), kaldi::ReadBasicType(), and Component::Type().
void Scale | ( | BaseFloat | scale | ) |
Definition at line 356 of file nnet-component.cc.
Referenced by Nnet::AddNnet(), Nnet::CopyStatsFrom(), main(), Nnet::Scale(), Nnet::SetZero(), and Nnet::ZeroStats().
void SetDim | ( | int32 | dim | ) |
Definition at line 321 of file nnet-component.cc.
References KALDI_ASSERT.
|
protected |
Definition at line 329 of file nnet-component.cc.
References CuVectorBase< Real >::AddRowSumMat(), CuMatrixBase< Real >::Dim(), Component::InputDim(), KALDI_ASSERT, CuMatrixBase< Real >::NumCols(), and CuMatrixBase< Real >::NumRows().
Referenced by SigmoidComponent::Backprop(), TanhComponent::Backprop(), RectifiedLinearComponent::Backprop(), SoftHingeComponent::Backprop(), SoftmaxComponent::Backprop(), and LogSoftmaxComponent::Backprop().
|
inline |
Definition at line 377 of file nnet-component.h.
Referenced by NnetStats::AddStatsFromNnet().
|
virtual |
Write component to stream.
Implements Component.
Reimplemented in PowerComponent.
Definition at line 389 of file nnet-component.cc.
References Component::Type(), kaldi::WriteBasicType(), and kaldi::WriteToken().
|
friend |
Definition at line 389 of file nnet-component.h.
|
friend |
Definition at line 385 of file nnet-component.h.
|
friend |
Definition at line 390 of file nnet-component.h.
|
friend |
Definition at line 386 of file nnet-component.h.
|
friend |
Definition at line 391 of file nnet-component.h.
|
friend |
Definition at line 388 of file nnet-component.h.
|
friend |
Definition at line 387 of file nnet-component.h.
|
protected |
Definition at line 406 of file nnet-component.h.
Referenced by NonlinearComponent::Add(), and SoftmaxComponent::MixUp().
|
protected |
Definition at line 404 of file nnet-component.h.
Referenced by NonlinearComponent::Add().
|
protected |
Definition at line 402 of file nnet-component.h.
Referenced by PowerComponent::Info(), ScaleComponent::Info(), PowerComponent::Init(), ScaleComponent::Init(), SoftmaxComponent::MixUp(), PowerComponent::Read(), ScaleComponent::Read(), PowerComponent::Write(), and ScaleComponent::Write().
|
protected |
Definition at line 408 of file nnet-component.h.
|
protected |
Definition at line 403 of file nnet-component.h.
Referenced by NonlinearComponent::Add(), and SoftmaxComponent::MixUp().