87 for (
int i = 0;
i < N;
i++) {
95 std::string s_lowercase(s);
96 std::transform(s.begin(), s.end(), s_lowercase.begin(), ::tolower);
98 for (
int i = 0;
i < N;
i++) {
100 std::string m_lowercase(m);
101 std::transform(m.begin(), m.end(), m_lowercase.begin(), ::tolower);
102 if (s_lowercase == m_lowercase)
return kMarkerMap[
i].key;
104 KALDI_ERR <<
"Unknown 'Component' marker : '" << s <<
"'\n" 105 <<
"(isn't the model 'too old' or incompatible?)";
133 ans =
new Softmax(input_dim, output_dim);
142 ans =
new Sigmoid(input_dim, output_dim);
145 ans =
new Tanh(input_dim, output_dim);
151 ans =
new Dropout(input_dim, output_dim);
157 ans =
new Rbm(input_dim, output_dim);
160 ans =
new Splice(input_dim, output_dim);
166 ans =
new AddShift(input_dim, output_dim);
169 ans =
new Rescale(input_dim, output_dim);
172 ans =
new KlHmm(input_dim, output_dim);
204 std::istringstream is(conf_line);
205 std::string component_type_string;
206 int32 input_dim, output_dim;
209 ReadToken(is,
false, &component_type_string);
225 int32 dim_out, dim_in;
228 int first_char =
Peek(is, binary);
229 if (first_char == EOF)
return NULL;
233 if (token ==
"<Nnet>") {
237 if (token ==
"</Nnet>") {
252 if (
'<' ==
Peek(is, binary) &&
'!' ==
PeekToken(is, binary)) {
264 if (!binary) os <<
"\n";
267 if (!binary) os <<
"\n";
Deprecated!!!, keeping it as Katka Zmolikova used it in JSALT 2015.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
ConvolutionalComponent implements convolution over single axis (i.e.
MaxPoolingComponent : The input/output matrices are split to submatrices with width 'pool_stride_'...
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...
Rearrange the matrix columns according to the indices in copy_from_indices_.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
static Component * Init(const std::string &conf_line)
Initialize component from a line in config file,.
static Component * Read(std::istream &is, bool binary)
Read the component from a stream (static method),.
int Peek(std::istream &is, bool binary)
Peek consumes whitespace (if binary == false) and then returns the peek() value of the stream...
ComponentType
Component type identification mechanism,.
Rescale the data column-wise by a vector (can be used for global variance normalization) ...
virtual void ReadData(std::istream &is, bool binary)
Reads the component content.
A pair of type and marker,.
static const struct key_value kMarkerMap[]
The table with pairs of Component types and markers (defined in nnet-component.cc),.
Rescale the matrix-rows to have unit length (L2-norm).
static const char * TypeToMarker(ComponentType t)
Converts component type to marker,.
const Component::ComponentType key
Adds shift to all the lines of the matrix (can be used for global mean normalization) ...
void Write(std::ostream &os, bool binary) const
Write the component to a stream,.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
int32 InputDim() const
Get the dimension of the input,.
static ComponentType MarkerToType(const std::string &s)
Converts marker to component type (case insensitive),.
virtual void WriteData(std::ostream &os, bool binary) const
Writes the component content.
virtual void InitData(std::istream &is)
Virtual interface for initialization and I/O,.
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
int PeekToken(std::istream &is, bool binary)
PeekToken will return the first character of the next token, or -1 if end of file.
void Splice(const CuMatrixBase< Real > &src, const CuArray< int32 > &frame_offsets, CuMatrixBase< Real > *tgt)
Splice concatenates frames of src as specified in frame_offsets into tgt.
Component with recurrent connections, 'tanh' non-linearity.
virtual ComponentType GetType() const =0
Get Type Identification of the component,.
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...
Abstract class, building block of the network.
AveragePoolingComponent : The input/output matrices are split to submatrices with width 'pool_stride_...
int32 OutputDim() const
Get the dimension of the output,.
SimpleSentenceAveragingComponent does not have nested network, it is intended to be used inside of a ...
FramePoolingComponent : The input/output matrices are split to frames of width 'feature_dim_'.
static Component * NewComponentOfType(ComponentType t, int32 input_dim, int32 output_dim)
Private members (descending classes cannot call this),.