26 using namespace kaldi;
58 template<
class RandomAccessIterator>
59 static void AssertEqual(RandomAccessIterator begin1, RandomAccessIterator end1,
60 RandomAccessIterator begin2, RandomAccessIterator end2) {
63 for ( ; begin1 < end1; ++begin1, ++begin2) {
75 const std::vector<int32>& m = r.
Generate(5);
77 int32 sum_of_elems = std::accumulate(m.begin(), m.end(),0);
95 std::vector<int32> mask(1111);
127 static_cast<const void>(m3);
145 std::vector<int32> mask(1111);
173 static_cast<const void>(v2);
180 std::vector<int32> v(1111);
181 for (
int32 i = 0;
i < v.size();
i++) {
184 std::random_shuffle(v.begin(), v.end());
189 c.minibatch_size = 100;
196 std::vector<int32> mask(1111);
205 std::vector<int32> v2 = r.
Value();
208 v.begin() + (i * c.minibatch_size),
209 v.begin() + ((i+1) * c.minibatch_size));
220 std::vector<int32> v2 = r.
Value();
221 AssertEqual(v2.begin(), v2.begin()+11, v.begin()+1100, v.begin()+1100+11);
226 std::vector<int32> v2 = r.
Value();
238 std::cout <<
"Tests succeeded.\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool IsFull()
Returns true, when capacity is full.
void UnitTestMatrixRandomizer()
bool Done()
Returns true, if no more data for another mini-batch (after current one)
void Next()
Sets cursor to next mini-batch.
void CopyToMat(MatrixBase< OtherReal > *dst, MatrixTransposeType trans=kNoTrans) const
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Real Cond() const
Returns condition number by computing Svd.
Base class which provides matrix operations not involving resizing or allocation. ...
void Next()
Sets cursor to next mini-batch.
Generates randomly ordered vector of indices,.
bool Done()
Returns true, if no more data for another mini-batch (after current one)
Randomizes elements of a vector according to a mask.
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void Init(const NnetDataRandomizerOptions &conf)
Set the randomizer parameters (size)
bool Done()
Returns true, if no more data for another mini-batch (after current one)
int32 randomizer_size
Maximum number of samples we have in memory,.
const std::vector< T > & Value()
Returns matrix-window with next mini-batch.
static void InitRand(VectorBase< Real > *v)
int32 NumFrames()
Number of frames stored inside the Randomizer.
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using mask.
int32 NumFrames()
Number of frames stored inside the Randomizer.
void AddData(const Vector< BaseFloat > &v)
Add data to randomization buffer.
void Next()
Sets cursor to next mini-batch.
Configuration variables that affect how frame-level shuffling is done.
void UnitTestVectorRandomizer()
void Init(const NnetDataRandomizerOptions &conf)
Init, call srand,.
void Init(const NnetDataRandomizerOptions &conf)
Set the randomizer parameters (size)
int32 NumFrames()
Number of frames stored inside the Randomizer.
void RandGauss(BaseFloat mu, BaseFloat sigma, CuMatrixBase< Real > *mat, struct RandomState *state=NULL)
Fill CuMatrix with random numbers (Gaussian distribution): mu = the mean value, sigma = standard devi...
void UnitTestRandomizerMask()
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using mask.
MatrixIndexT Dim() const
Returns the dimension of the vector.
void UnitTestStdVectorRandomizer()
const CuMatrixBase< BaseFloat > & Value()
Returns matrix-window with next mini-batch.
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using mask.
Shuffles rows of a matrix according to the indices in the mask,.
Matrix for CUDA computing.
MatrixIndexT NumCols() const
const std::vector< int32 > & Generate(int32 mask_size)
Generate randomly ordered vector of integers 0..[mask_size -1],.
SubMatrix< Real > RowRange(const MatrixIndexT row_offset, const MatrixIndexT num_rows) const
A class representing a vector.
#define KALDI_ASSERT(cond)
bool IsFull()
Returns true, when capacity is full.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
void Init(const NnetDataRandomizerOptions &conf)
Set the randomizer parameters (size)
void AddData(const std::vector< T > &v)
Add data to randomization buffer.
Randomizes elements of a vector according to a mask.
MatrixIndexT NumRows() const
Dimensions.
Provides a vector abstraction class.
void AddData(const CuMatrixBase< BaseFloat > &m)
Add data to randomization buffer.
bool IsFull()
Returns true, when capacity is full.
const Vector< BaseFloat > & Value()
Returns matrix-window with next mini-batch.
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).