@@ -251,9 +251,9 @@ void SlidingWindowCmnInternal(const SlidingWindowCmnOptions &opts,
251251 const MatrixBase<double > &input,
252252 MatrixBase<double > *output) {
253253 opts.Check ();
254- int32 num_frames = input.NumRows (), dim = input.NumCols ();
255-
256- int32 last_window_start = - 1 , last_window_end = - 1 ;
254+ int32 num_frames = input.NumRows (), dim = input.NumCols (),
255+ last_window_start = - 1 , last_window_end = - 1 ,
256+ warning_count = 0 ;
257257 Vector<double > cur_sum (dim), cur_sumsq (dim);
258258
259259 for (int32 t = 0 ; t < num_frames; t++) {
@@ -323,8 +323,20 @@ void SlidingWindowCmnInternal(const SlidingWindowCmnOptions &opts,
323323 // around their own mean.
324324 int32 num_floored = variance.ApplyFloor (1.0e-10 );
325325 if (num_floored > 0 && num_frames > 1 ) {
326- KALDI_WARN << " Flooring variance When normalizing variance, floored " << num_floored
327- << " elements; num-frames was " << window_frames;
326+ if (opts.max_warnings == warning_count) {
327+ KALDI_WARN << " Suppressing the remaining variance flooring "
328+ << " warnings. Run program with --max-warnings=-1 to "
329+ << " see all warnings." ;
330+ }
331+ // If opts.max_warnings is a negative number, we won't restrict the
332+ // number of times that the warning is printed out.
333+ else if (opts.max_warnings < 0
334+ || opts.max_warnings > warning_count) {
335+ KALDI_WARN << " Flooring when normalizing variance, floored "
336+ << num_floored << " elements; num-frames was "
337+ << window_frames;
338+ }
339+ warning_count++;
328340 }
329341 variance.ApplyPow (-0.5 ); // get inverse standard deviation.
330342 output_frame.MulElements (variance);
@@ -339,7 +351,7 @@ void SlidingWindowCmn(const SlidingWindowCmnOptions &opts,
339351 MatrixBase<BaseFloat> *output) {
340352 KALDI_ASSERT (SameDim (input, *output) && input.NumRows () > 0 );
341353 Matrix<double > input_dbl (input), output_dbl (input.NumRows (), input.NumCols ());
342- // calll double-precision version
354+ // call double-precision version
343355 SlidingWindowCmnInternal (opts, input_dbl, &output_dbl);
344356 output->CopyFromMat (output_dbl);
345357}
0 commit comments