diff --git a/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py b/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py index 5566b849974..a62c648c15f 100644 --- a/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py +++ b/tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py @@ -283,6 +283,9 @@ def _split(self, wav, label): ]) def _preprocess(self, x, label): """Preprocess the dataset to extract the spectrum.""" + # Add small Gaussian noise to the input x + # to solve the potential "nan" problem of the preprocess_model. + x = x + 1e-05 * tf.random.normal(x.shape) # x has shape (1, EXPECTED_WAVEFORM_LENGTH) spectrum = self._preprocess_model(x) # y has shape (1, embedding_len)