nnet-test-utils.h
Go to the documentation of this file.
1 // nnet3/nnet-test-utils.h
2 
3 // Copyright 2015 Johns Hopkins University (author: Daniel Povey)
4 // Copyright 2016 Daniel Galvez
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #ifndef KALDI_NNET3_NNET_TEST_UTILS_H_
21 #define KALDI_NNET3_NNET_TEST_UTILS_H_
22 
23 #include "nnet3/nnet-nnet.h"
24 #include "nnet3/nnet-utils.h"
25 #include "nnet3/nnet-example.h"
26 
27 namespace kaldi {
28 namespace nnet3 {
29 
44  // if set to a value >0, the output-dim of the network
45  // will be set to this value.
47 
49  allow_context(true),
50  allow_nonlinearity(true),
51  allow_recursion(true),
52  allow_clockwork(true),
53  allow_multiple_inputs(true),
54  allow_multiple_outputs(false),
55  allow_final_nonlinearity(true),
56  allow_use_of_x_dim(true),
57  allow_ivector(false),
58  allow_statistics_pooling(true),
59  output_dim(-1) { }
60 };
61 
66  std::vector<std::string> *configs);
67 
72  std::vector<std::string> *configs);
73 
85  const Nnet &nnet,
86  ComputationRequest *request,
87  std::vector<Matrix<BaseFloat> > *inputs);
88 
90 
91 
96 bool NnetParametersAreIdentical(const Nnet &nnet1,
97  const Nnet &nnet2,
98  BaseFloat threshold);
99 
100 
107  int32 num_supervised_frames,
108  int32 left_context,
109  int32 right_context,
110  int32 input_dim,
112  int32 ivector_dim,
113  NnetExample *example);
114 
115 
118 bool ExampleApproxEqual(const NnetExample &eg1,
119  const NnetExample &eg2,
120  BaseFloat delta);
121 
122 } // namespace nnet3
123 } // namespace kaldi
124 
125 #endif
NnetExample is the input data and corresponding label (or labels) for one or more frames of input...
Definition: nnet-example.h:111
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void GenerateSimpleNnetTrainingExample(int32 num_supervised_frames, int32 left_context, int32 right_context, int32 output_dim, int32 input_dim, int32 ivector_dim, NnetExample *example)
Low-level function that generates an nnet training example.
bool NnetParametersAreIdentical(const Nnet &nnet1, const Nnet &nnet2, BaseFloat threshold=1.0e-05)
Used for testing that the updatable parameters in two networks are the same.
Abstract base-class for neural-net components.
kaldi::int32 int32
This file contains some miscellaneous functions dealing with class Nnet.
void ComputeExampleComputationRequestSimple(const Nnet &nnet, ComputationRequest *request, std::vector< Matrix< BaseFloat > > *inputs)
This function computes an example computation request, for testing purposes.
bool ExampleApproxEqual(const NnetExample &eg1, const NnetExample &eg2, BaseFloat delta)
Returns true if the examples are approximately equal (only intended to be used in testing)...
void GenerateConfigSequence(const NnetGenerationOptions &opts, std::vector< std::string > *configs)
Generates a sequence of at least one config files, output as strings, where the first in the sequence...
void GenerateConfigSequenceCompositeBlock(const NnetGenerationOptions &opts, std::vector< std::string > *configs)
Generate a config string with a composite component composed only of block affine, repeated affine, and natural gradient repeated affine components.
Component * GenerateRandomSimpleComponent()
Generates random simple component for testing.