#include <nnet-component.h>
Public Member Functions | |
void | Init (BaseFloat learning_rate, int32 input_dim, int32 output_dim, BaseFloat param_stddev, BaseFloat bias_stddev, int32 num_blocks, BaseFloat alpha) |
virtual void | InitFromString (std::string args) |
Initialize, typically from a line of a config file. More... | |
BlockAffineComponentPreconditioned () | |
virtual std::string | Type () const |
virtual void | SetZero (bool treat_as_gradient) |
Set parameters to zero, and if treat_as_gradient is true, we'll be treating this as a gradient so set the learning rate to 1 and make any other changes necessary (there's a variable we have to set for the MixtureProbComponent). More... | |
virtual void | Read (std::istream &is, bool binary) |
virtual void | Write (std::ostream &os, bool binary) const |
Write component to stream. More... | |
virtual Component * | Copy () const |
Copy component (deep copy). More... | |
Public Member Functions inherited from BlockAffineComponent | |
virtual int32 | InputDim () const |
Get size of input vectors. More... | |
virtual int32 | OutputDim () const |
Get size of output vectors. More... | |
virtual int32 | GetParameterDim () const |
The following new virtual function returns the total dimension of the parameters in this class. More... | |
virtual void | Vectorize (VectorBase< BaseFloat > *params) const |
Turns the parameters into vector form. More... | |
virtual void | UnVectorize (const VectorBase< BaseFloat > ¶ms) |
Converts the parameters from vector form. More... | |
void | Init (BaseFloat learning_rate, int32 input_dim, int32 output_dim, BaseFloat param_stddev, BaseFloat bias_stddev, int32 num_blocks) |
BlockAffineComponent () | |
virtual bool | BackpropNeedsInput () const |
virtual bool | BackpropNeedsOutput () const |
virtual void | Propagate (const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const |
Perform forward pass propagation Input->Output. 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 |
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 BaseFloat | DotProduct (const UpdatableComponent &other) const |
Here, "other" is a component of the same specific type. More... | |
virtual void | PerturbParams (BaseFloat stddev) |
We introduce a new virtual function that only applies to class UpdatableComponent. More... | |
virtual void | Scale (BaseFloat scale) |
This new virtual function scales the parameters by this amount. More... | |
virtual void | Add (BaseFloat alpha, const UpdatableComponent &other) |
This new virtual function adds the parameters of another updatable component, times some constant, to the current parameters. More... | |
Public Member Functions inherited from UpdatableComponent | |
UpdatableComponent (const UpdatableComponent &other) | |
void | Init (BaseFloat learning_rate) |
UpdatableComponent (BaseFloat learning_rate) | |
UpdatableComponent () | |
virtual | ~UpdatableComponent () |
void | SetLearningRate (BaseFloat lrate) |
Sets the learning rate of gradient descent. More... | |
BaseFloat | LearningRate () const |
Gets the learning rate of gradient descent. More... | |
virtual std::string | Info () const |
Public Member Functions inherited from Component | |
Component () | |
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... | |
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 | ~Component () |
Private Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (BlockAffineComponentPreconditioned) | |
virtual void | Update (const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv) |
Private Attributes | |
bool | is_gradient_ |
BaseFloat | alpha_ |
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... | |
Protected Member Functions inherited from BlockAffineComponent | |
virtual void | UpdateSimple (const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv) |
Protected Attributes inherited from BlockAffineComponent | |
CuMatrix< BaseFloat > | linear_params_ |
CuVector< BaseFloat > | bias_params_ |
int32 | num_blocks_ |
Protected Attributes inherited from UpdatableComponent | |
BaseFloat | learning_rate_ |
learning rate (0.0..0.01) More... | |
Definition at line 1242 of file nnet-component.h.
|
inline |
Definition at line 1252 of file nnet-component.h.
|
virtual |
Copy component (deep copy).
Reimplemented from BlockAffineComponent.
Definition at line 2241 of file nnet-component.cc.
References AffineComponentPreconditionedOnline::alpha_, BlockAffineComponentPreconditioned::alpha_, AffineComponent::bias_params_, BlockAffineComponent::bias_params_, AffineComponent::is_gradient_, BlockAffineComponentPreconditioned::is_gradient_, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, BlockAffineComponent::linear_params_, and BlockAffineComponent::num_blocks_.
void Init | ( | BaseFloat | learning_rate, |
int32 | input_dim, | ||
int32 | output_dim, | ||
BaseFloat | param_stddev, | ||
BaseFloat | bias_stddev, | ||
int32 | num_blocks, | ||
BaseFloat | alpha | ||
) |
Definition at line 2161 of file nnet-component.cc.
References AffineComponentPreconditionedOnline::alpha_, BlockAffineComponent::Init(), AffineComponent::is_gradient_, and KALDI_ASSERT.
Referenced by kaldi::nnet2::UnitTestBlockAffineComponentPreconditioned().
|
virtual |
Initialize, typically from a line of a config file.
The "args" will contain any parameters that need to be passed to the Component, e.g. dimensions.
Reimplemented from BlockAffineComponent.
Definition at line 2174 of file nnet-component.cc.
References AffineComponentPreconditionedOnline::Init(), KALDI_ERR, UpdatableComponent::learning_rate_, and kaldi::nnet2::ParseFromString().
Referenced by kaldi::nnet2::UnitTestBlockAffineComponentPreconditioned().
|
private |
|
virtual |
Reimplemented from BlockAffineComponent.
Definition at line 2206 of file nnet-component.cc.
References AffineComponentPreconditionedOnline::alpha_, AffineComponent::bias_params_, kaldi::nnet2::ExpectOneOrTwoTokens(), kaldi::ExpectToken(), AffineComponent::is_gradient_, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, and kaldi::ReadBasicType().
|
virtual |
Set parameters to zero, and if treat_as_gradient is true, we'll be treating this as a gradient so set the learning rate to 1 and make any other changes necessary (there's a variable we have to set for the MixtureProbComponent).
Reimplemented from BlockAffineComponent.
Definition at line 2200 of file nnet-component.cc.
References AffineComponent::is_gradient_, and BlockAffineComponent::SetZero().
|
inlinevirtual |
Reimplemented from BlockAffineComponent.
Definition at line 1253 of file nnet-component.h.
References kaldi::cu::Copy(), and KALDI_DISALLOW_COPY_AND_ASSIGN.
|
privatevirtual |
Reimplemented from BlockAffineComponent.
Definition at line 2253 of file nnet-component.cc.
References CuMatrixBase< Real >::AddMatMat(), AffineComponentPreconditionedOnline::alpha_, AffineComponent::bias_params_, CuVectorBase< Real >::CopyColFromMat(), CuMatrixBase< Real >::CopyFromMat(), AffineComponent::is_gradient_, kaldi::kNoTrans, kaldi::kTrans, kaldi::kUndefined, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, CuMatrixBase< Real >::NumRows(), kaldi::nnet2::PreconditionDirectionsAlphaRescaled(), and AffineComponent::UpdateSimple().
|
virtual |
Write component to stream.
Reimplemented from BlockAffineComponent.
Definition at line 2223 of file nnet-component.cc.
References AffineComponentPreconditionedOnline::alpha_, AffineComponent::bias_params_, AffineComponent::is_gradient_, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, kaldi::WriteBasicType(), and kaldi::WriteToken().
|
private |
Definition at line 1265 of file nnet-component.h.
Referenced by BlockAffineComponentPreconditioned::Copy().
|
private |
Definition at line 1264 of file nnet-component.h.
Referenced by BlockAffineComponentPreconditioned::Copy().