37 mask_.resize(mask_size);
40 std::random_shuffle(
mask_.begin(),
mask_.end());
49 if (
data_.NumCols() == 0) {
53 if (data_begin_ > 0) {
55 int32 leftover = data_end_ - data_begin_;
58 data_.RowRange(0, leftover).CopyFromMat(
data_.RowRange(data_begin_, leftover));
63 data_.RowRange(leftover,
data_.NumRows() - leftover).SetZero();
72 data_.RowRange(0, data_aux.
NumRows()).CopyFromMat(data_aux);
99 data_begin_ += conf_.minibatch_size;
104 KALDI_ASSERT(data_end_ - data_begin_ >= conf_.minibatch_size);
107 minibatch_.CopyFromMat(
data_.RowRange(data_begin_, conf_.minibatch_size));
116 if (
data_.Dim() == 0) {
117 data_.Resize(conf_.randomizer_size);
120 if (data_begin_ > 0) {
122 int32 leftover = data_end_ - data_begin_;
125 data_.Range(0, leftover).CopyFromVec(
data_.Range(data_begin_, leftover));
128 data_end_ = leftover;
129 data_.Range(leftover,
data_.Dim()-leftover).SetZero();
132 if (
data_.Dim() < data_end_ + v.
Dim()) {
134 data_.Resize(data_end_ + v.
Dim() + 1000);
135 data_.Range(0, data_aux.
Dim()).CopyFromVec(data_aux);
138 data_.Range(data_end_, v.
Dim()).CopyFromVec(v);
139 data_end_ += v.
Dim();
149 for (
int32 i = 0;
i < mask.size();
i++) {
150 data_(
i) = data_aux(mask.at(
i));
155 data_begin_ += conf_.minibatch_size;
160 KALDI_ASSERT(data_end_ - data_begin_ >= conf_.minibatch_size);
162 minibatch_.Resize(conf_.minibatch_size,
kUndefined);
163 minibatch_.CopyFromVec(
data_.Range(data_begin_, conf_.minibatch_size));
173 if (
data_.size() == 0) {
174 data_.resize(conf_.randomizer_size);
177 if (data_begin_ > 0) {
179 int32 leftover = data_end_ - data_begin_;
182 typename std::vector<T>::iterator leftover_begin =
data_.begin() + data_begin_;
183 std::copy(leftover_begin, leftover_begin + leftover,
data_.begin());
186 data_end_ = leftover;
189 if (
data_.size() < data_end_ + v.size()) {
190 data_.resize(data_end_ + v.size() + 1000);
193 std::copy(v.begin(), v.end(),
data_.begin()+data_end_);
194 data_end_ += v.size();
203 std::vector<T> data_aux(
data_);
205 for (
int32 i = 0;
i < mask.size();
i++) {
206 data_.at(
i) = data_aux.at(mask.at(
i));
212 data_begin_ += conf_.minibatch_size;
218 KALDI_ASSERT(data_end_ - data_begin_ >= conf_.minibatch_size);
220 minibatch_.resize(conf_.minibatch_size);
221 typename std::vector<T>::iterator first =
data_.begin() + data_begin_;
222 typename std::vector<T>::iterator last = first + conf_.minibatch_size;
223 std::copy(first, last, minibatch_.begin());
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void CopyFromVec(const std::vector< T > &src)
This function resizes if needed.
void Next()
Sets cursor to next mini-batch.
void Randomize(const CuMatrixBase< Real > &src, const CuArray< int32 > ©_from_idx, CuMatrixBase< Real > *tgt)
Copies a permutation of src into tgt.
void Next()
Sets cursor to next mini-batch.
const std::vector< T > & Value()
Returns matrix-window with next mini-batch.
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using mask.
void AddData(const Vector< BaseFloat > &v)
Add data to randomization buffer.
void Next()
Sets cursor to next mini-batch.
std::vector< int32 > mask_
Configuration variables that affect how frame-level shuffling is done.
void Init(const NnetDataRandomizerOptions &conf)
Init, call srand,.
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using mask.
MatrixIndexT Dim() const
Returns the dimension of the vector.
const CuMatrixBase< BaseFloat > & Value()
Returns matrix-window with next mini-batch.
void Randomize(const std::vector< int32 > &mask)
Randomize matrix row-order using 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],.
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
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.
void AddData(const CuMatrixBase< BaseFloat > &m)
Add data to randomization buffer.
const Vector< BaseFloat > & Value()
Returns matrix-window with next mini-batch.