30 int32 input_dim = 10 + rand() % 40, output_dim = 100 + rand() % 500;
31 bool pad_input = (rand() % 2 == 0);
35 << nnet->
RightContext() <<
", pad-input = " << pad_input;
37 int32 num_feats = 5 + rand() % 1000;
41 int32 num_output_rows = num_feats -
43 if (num_output_rows <= 0)
48 int32 cur_input_pos = 0, cur_output_pos = 0;
51 while (cur_input_pos <= num_feats) {
52 int32 feats_left = num_feats - cur_input_pos;
55 int32 chunk_size = std::min<int32>(1 + rand() % 10, feats_left);
58 computer.
Compute(input_part, &output_part);
59 cur_input_pos += chunk_size;
61 computer.
Flush(&output_part);
64 if (output_part.
NumRows() != 0) {
65 output2.Range(cur_output_pos, output_part.
NumRows(),
66 0, output_dim).CopyFromMat(output_part);
67 cur_output_pos += output_part.
NumRows();
74 if (
i < 10 || output1.
NumRows() -
i < 10) {
84 int32 input_dim = 10 + rand() % 40, output_dim = 100 + rand() % 500;
85 bool pad_input =
true;
88 int32 num_feats = 100 + rand() % 500;
89 int32 chunk_size = num_feats / (2 + rand() % 10);
95 <<
", chunk size = " << chunk_size;
98 int32 num_output_rows = num_feats;
110 if (
i < 10 || output1.
NumRows() -
i < 10) {
126 using namespace kaldi;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 LeftContext() const
Returns the left-context summed over all the Components...
Nnet * GenRandomNnet(int32 input_dim, int32 output_dim)
This function generates a random neural net, for testing purposes.
void NnetComputationChunked(const Nnet &nnet, const CuMatrixBase< BaseFloat > &input, int32 chunk_size, CuMatrixBase< BaseFloat > *output)
Does the basic neural net computation, on a sequence of data (e.g.
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void NnetComputation(const Nnet &nnet, const CuMatrixBase< BaseFloat > &input, bool pad_input, CuMatrixBase< BaseFloat > *output)
Does the basic neural net computation, on a sequence of data (e.g.
void Flush(CuMatrix< BaseFloat > *output)
void UnitTestNnetComputeChunked()
int32 RightContext() const
Returns the right-context summed over all the Components...
void UnitTestNnetCompute()
This class is used for a piece of a CuMatrix.
MatrixIndexT NumCols() const
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Compute(const CuMatrixBase< BaseFloat > &input, CuMatrix< BaseFloat > *output)
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
MatrixIndexT NumRows() const
Dimensions.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...