#include <nnet-component.h>
Public Member Functions | |
virtual std::string | Type () const |
virtual void | Read (std::istream &is, bool binary) |
virtual void | Write (std::ostream &os, bool binary) const |
Write component to stream. More... | |
void | Init (BaseFloat learning_rate, int32 input_dim, int32 output_dim, BaseFloat param_stddev, BaseFloat bias_stddev, BaseFloat alpha, BaseFloat max_change) |
void | Init (BaseFloat learning_rate, BaseFloat alpha, BaseFloat max_change, std::string matrix_filename) |
virtual void | InitFromString (std::string args) |
Initialize, typically from a line of a config file. More... | |
virtual std::string | Info () const |
virtual Component * | Copy () const |
Copy component (deep copy). More... | |
AffineComponentPreconditioned () | |
void | SetMaxChange (BaseFloat max_change) |
Public Member Functions inherited from AffineComponent | |
AffineComponent (const AffineComponent &other) | |
AffineComponent (const CuMatrixBase< BaseFloat > &linear_params, const CuVectorBase< BaseFloat > &bias_params, BaseFloat learning_rate) | |
virtual int32 | InputDim () const |
Get size of input vectors. More... | |
virtual int32 | OutputDim () const |
Get size of output vectors. More... | |
void | Init (BaseFloat learning_rate, int32 input_dim, int32 output_dim, BaseFloat param_stddev, BaseFloat bias_stddev) |
void | Init (BaseFloat learning_rate, std::string matrix_filename) |
virtual void | Resize (int32 input_dim, int32 output_dim) |
Component * | CollapseWithNext (const AffineComponent &next) const |
Component * | CollapseWithNext (const FixedAffineComponent &next) const |
Component * | CollapseWithNext (const FixedScaleComponent &next) const |
Component * | CollapseWithPrevious (const FixedAffineComponent &prev) const |
AffineComponent () | |
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 | 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... | |
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 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 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 | SetParams (const VectorBase< BaseFloat > &bias, const MatrixBase< BaseFloat > &linear) |
const CuVector< BaseFloat > & | BiasParams () |
const CuMatrix< BaseFloat > & | LinearParams () |
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... | |
virtual void | LimitRank (int32 dimension, AffineComponent **a, AffineComponent **b) const |
This function is for getting a low-rank approximations of this AffineComponent by two AffineComponents. More... | |
void | Widen (int32 new_dimension, BaseFloat param_stddev, BaseFloat bias_stddev, std::vector< NonlinearComponent *> c2, AffineComponent *c3) |
This function is implemented in widen-nnet.cc. 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... | |
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 () |
Protected Member Functions | |
KALDI_DISALLOW_COPY_AND_ASSIGN (AffineComponentPreconditioned) | |
BaseFloat | GetScalingFactor (const CuMatrix< BaseFloat > &in_value_precon, const CuMatrix< BaseFloat > &out_deriv_precon) |
The following function is only called if max_change_ > 0. More... | |
virtual void | Update (const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv) |
Protected Member Functions inherited from AffineComponent | |
virtual void | UpdateSimple (const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv) |
const AffineComponent & | operator= (const AffineComponent &other) |
Protected Attributes | |
BaseFloat | alpha_ |
BaseFloat | max_change_ |
Protected Attributes inherited from AffineComponent | |
CuMatrix< BaseFloat > | linear_params_ |
CuVector< BaseFloat > | bias_params_ |
bool | is_gradient_ |
Protected Attributes inherited from UpdatableComponent | |
BaseFloat | learning_rate_ |
learning rate (0.0..0.01) More... | |
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... | |
Definition at line 948 of file nnet-component.h.
|
inline |
Definition at line 964 of file nnet-component.h.
|
virtual |
Copy component (deep copy).
Reimplemented from AffineComponent.
Definition at line 1500 of file nnet-component.cc.
References AffineComponentPreconditioned::alpha_, AffineComponent::bias_params_, AffineComponent::is_gradient_, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, and AffineComponentPreconditioned::max_change_.
|
protected |
The following function is only called if max_change_ > 0.
It returns the greatest value alpha <= 1.0 such that (alpha times the sum over the row-index of the two matrices of the product the l2 norms of the two rows times learning_rate_) is <= max_change.
Definition at line 1512 of file nnet-component.cc.
References CuVectorBase< Real >::AddDiagMat2(), Component::Index(), KALDI_ASSERT, KALDI_LOG, kaldi::kNoTrans, UpdatableComponent::learning_rate_, CuMatrixBase< Real >::NumRows(), and kaldi::VecVec().
|
virtual |
Reimplemented from AffineComponent.
Definition at line 1481 of file nnet-component.cc.
References AffineComponent::bias_params_, AffineComponent::InputDim(), kaldi::kTrans, UpdatableComponent::LearningRate(), AffineComponent::linear_params_, AffineComponent::OutputDim(), kaldi::TraceMatMat(), AffineComponent::Type(), and kaldi::VecVec().
void Init | ( | BaseFloat | learning_rate, |
int32 | input_dim, | ||
int32 | output_dim, | ||
BaseFloat | param_stddev, | ||
BaseFloat | bias_stddev, | ||
BaseFloat | alpha, | ||
BaseFloat | max_change | ||
) |
Definition at line 1442 of file nnet-component.cc.
References AffineComponent::bias_params_, UpdatableComponent::Init(), KALDI_ASSERT, and AffineComponent::linear_params_.
Referenced by kaldi::nnet2::UnitTestAffineComponentPreconditioned().
void Init | ( | BaseFloat | learning_rate, |
BaseFloat | alpha, | ||
BaseFloat | max_change, | ||
std::string | matrix_filename | ||
) |
Definition at line 1426 of file nnet-component.cc.
References AffineComponent::bias_params_, UpdatableComponent::Init(), KALDI_ASSERT, AffineComponent::linear_params_, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), CuMatrixBase< Real >::Range(), and kaldi::ReadKaldiObject().
|
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 AffineComponent.
Definition at line 1390 of file nnet-component.cc.
References AffineComponent::Init(), AffineComponent::InputDim(), KALDI_ASSERT, KALDI_ERR, UpdatableComponent::learning_rate_, AffineComponent::OutputDim(), and kaldi::nnet2::ParseFromString().
Referenced by kaldi::nnet2::UnitTestAffineComponentPreconditioned().
|
protected |
|
virtual |
Reimplemented from AffineComponent.
Definition at line 1360 of file nnet-component.cc.
References AffineComponent::bias_params_, kaldi::nnet2::ExpectOneOrTwoTokens(), kaldi::ExpectToken(), KALDI_ASSERT, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, kaldi::ReadBasicType(), kaldi::ReadToken(), and AffineComponent::Type().
|
inline |
Definition at line 965 of file nnet-component.h.
References KALDI_DISALLOW_COPY_AND_ASSIGN.
Referenced by kaldi::nnet2::SetMaxChange().
|
inlinevirtual |
Reimplemented from AffineComponent.
Definition at line 950 of file nnet-component.h.
References kaldi::cu::Copy().
|
protectedvirtual |
Reimplemented from AffineComponent.
Definition at line 1544 of file nnet-component.cc.
References AffineComponent::bias_params_, CuVectorBase< Real >::CopyColFromMat(), kaldi::kNoTrans, kaldi::kTrans, kaldi::kUndefined, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, CuMatrixBase< Real >::NumCols(), CuMatrixBase< Real >::NumRows(), kaldi::nnet2::PreconditionDirectionsAlphaRescaled(), CuMatrixBase< Real >::Range(), and CuMatrix< Real >::Resize().
|
virtual |
Write component to stream.
Reimplemented from AffineComponent.
Definition at line 1463 of file nnet-component.cc.
References AffineComponent::bias_params_, UpdatableComponent::learning_rate_, AffineComponent::linear_params_, AffineComponent::Type(), kaldi::WriteBasicType(), and kaldi::WriteToken().
|
protected |
Definition at line 968 of file nnet-component.h.
Referenced by AffineComponentPreconditioned::Copy().
|
protected |
Definition at line 969 of file nnet-component.h.
Referenced by AffineComponentPreconditioned::Copy().