20 #ifndef KALDI_NNET3_NNET_CONVOLUTIONAL_COMPONENT_H_ 21 #define KALDI_NNET3_NNET_CONVOLUTIONAL_COMPONENT_H_ 212 class TimeHeightConvolutionComponent:
public UpdatableComponent {
224 virtual std::string
Info()
const;
226 virtual std::string
Type()
const {
return "TimeHeightConvolutionComponent"; }
234 virtual void Backprop(
const std::string &debug_info,
243 virtual void Read(std::istream &is,
bool binary);
244 virtual void Write(std::ostream &os,
bool binary)
const;
256 std::vector<Index> *output_indexes)
const;
259 const Index &output_index,
260 std::vector<Index> *desired_indexes)
const;
265 const Index &output_index,
267 std::vector<Index> *used_inputs)
const;
271 const std::vector<Index> &input_indexes,
272 const std::vector<Index> &output_indexes,
273 bool need_backprop)
const;
292 virtual void Write(std::ostream &os,
bool binary)
const;
293 virtual void Read(std::istream &os,
bool binary);
294 virtual std::string
Type()
const {
295 return "TimeHeightConvolutionComponentPrecomputedIndexes";
464 virtual std::string
Info()
const;
466 virtual std::string
Type()
const {
return "TdnnComponent"; }
475 virtual void Backprop(
const std::string &debug_info,
484 virtual void Read(std::istream &is,
bool binary);
485 virtual void Write(std::ostream &os,
bool binary)
const;
497 std::vector<Index> *output_indexes)
const;
500 const Index &output_index,
501 std::vector<Index> *desired_indexes)
const;
506 const Index &output_index,
508 std::vector<Index> *used_inputs)
const;
512 const std::vector<Index> &input_indexes,
513 const std::vector<Index> &output_indexes,
514 bool need_backprop)
const;
531 row_stride(other.row_stride), row_offsets(other.row_offsets) { }
533 virtual void Write(std::ostream &os,
bool binary)
const;
534 virtual void Read(std::istream &os,
bool binary);
535 virtual std::string
Type()
const {
536 return "TdnnComponentPrecomputedIndexes";
551 std::vector<int32> row_offsets;
571 int32 num_output_rows,
599 std::vector<int32> time_offsets_;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
virtual void Vectorize(VectorBase< BaseFloat > *params) const
Turns the parameters into vector form.
BaseFloat OrthonormalConstraint() const
Abstract base-class for neural-net components.
An abstract representation of a set of Indexes.
TdnnComponent is a more memory-efficient alternative to manually splicing several frames of input and...
void ScaleLinearParams(BaseFloat alpha)
This comment explains the basic framework used for everything related to time-height convolution...
virtual Component * Copy() const
Copies component (deep copy).
virtual ~PrecomputedIndexes()
virtual std::string Type() const
Keywords for search: natural gradient, naturalgradient, NG-SGD.
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
virtual void FreezeNaturalGradient(bool freeze)
freezes/unfreezes NaturalGradient updates, if applicable (to be overriden by components that use Natu...
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.
virtual void UnVectorize(const VectorBase< BaseFloat > ¶ms)
Converts the parameters from vector form.
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 pos...
CuMatrix< BaseFloat > linear_params_
void UpdateNaturalGradient(const PrecomputedIndexes &indexes, const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv)
virtual std::string Type() const
Returns a string such as "SigmoidComponent", describing the type of the object.
virtual void InitFromConfig(ConfigLine *cfl)
Initialize, from a ConfigLine object.
virtual void * Propagate(const ComponentPrecomputedIndexes *indexes, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const
Propagate function.
struct Index is intended to represent the various indexes by which we number the rows of the matrices...
virtual ComponentPrecomputedIndexes * PrecomputeIndexes(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.
OnlineNaturalGradient preconditioner_out_
virtual std::string Type() const
std::vector< int32 > all_time_offsets_
virtual PrecomputedIndexes * Copy() const
This file contains some fairly low-level utilities for implementing convolutional neural networks and...
CuMatrixBase< BaseFloat > & LinearParams()
virtual void Scale(BaseFloat scale)
This virtual function when called on – an UpdatableComponent scales the parameters by "scale" when c...
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...
TimeHeightConvolutionComponent()
virtual int32 InputDim() const
Returns input-dimension of this component.
virtual void Add(BaseFloat alpha, const Component &other)
This virtual function when called by – an UpdatableComponent adds the parameters of another updatabl...
PrecomputedIndexes(const PrecomputedIndexes &other)
virtual void Write(std::ostream &os, bool binary) const
virtual int32 Properties() const
Return bitmask of the component's properties.
virtual void ReorderIndexes(std::vector< Index > *input_indexes, std::vector< Index > *output_indexes) const
This function only does something interesting for non-simple Components.
CuVector< BaseFloat > & BiasParams()
time_height_convolution::ConvolutionModel model_
virtual int32 Properties() const
Return bitmask of the component's properties.
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 *to_update, CuMatrixBase< BaseFloat > *in_deriv) const
Backprop function; depending on which of the arguments 'to_update' and 'in_deriv' are non-NULL...
void UpdateSimple(const PrecomputedIndexes &indexes, const CuMatrixBase< BaseFloat > &in_value, const CuMatrixBase< BaseFloat > &out_deriv)
virtual int32 OutputDim() const
Returns output-dimension of this component.
This class is used for a piece of a CuMatrix.
virtual Component * Copy() const
Copies component (deep copy).
virtual BaseFloat DotProduct(const UpdatableComponent &other) const
Computes dot-product between parameters of two instances of a Component.
virtual void Write(std::ostream &os, bool binary) const
Write component to stream.
virtual int32 InputDim() const
Returns input-dimension of this component.
PrecomputedIndexes(const PrecomputedIndexes &other)
Class UpdatableComponent is a Component which has trainable parameters; it extends the interface of C...
virtual int32 OutputDim() const
Returns output-dimension of this component.
This struct represents the structure of a convolution computation.
Matrix for CUDA computing.
This class is responsible for parsing input like hi-there xx=yyy a=b c empty= f-oo=Append(bar, sss) ba_z=123 bing='a b c' baz="a b c d='a b' e" and giving you access to the fields, in this case.
virtual void PerturbParams(BaseFloat stddev)
This function is to be used in testing.
CuVector< BaseFloat > bias_params_
virtual void Read(std::istream &os, bool binary)
virtual int32 NumParameters() const
The following new virtual function returns the total dimension of the parameters in this class...
void ConsolidateMemory()
This virtual function relates to memory management, and avoiding fragmentation.
Provides a vector abstraction class.
bool use_natural_gradient_
OnlineNaturalGradient preconditioner_in_
std::vector< bool > time_offset_required_
virtual ~PrecomputedIndexes()
virtual std::string Type() const
Returns a string such as "SigmoidComponent", describing the type of the object.
virtual std::string Info() const
Returns some text-form information about this component, for diagnostics.
time_height_convolution::ConvolutionComputation computation