Skip to content

Commit 5d039b7

Browse files
authored
Update audio_spec.py
Fix the potential "nan" problem of the precrocess_model in BrowserFftSpec
1 parent eb9e434 commit 5d039b7

File tree

1 file changed

+2
-0
lines changed
  • tensorflow_examples/lite/model_maker/core/task/model_spec

1 file changed

+2
-0
lines changed

tensorflow_examples/lite/model_maker/core/task/model_spec/audio_spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ def _split(self, wav, label):
283283
])
284284
def _preprocess(self, x, label):
285285
"""Preprocess the dataset to extract the spectrum."""
286+
# Add small Gaussian noise to the input x to solve the potential "nan" problem of the preprocess_model
287+
x = x + 1e-05 * tf.random.normal(x.shape)
286288
# x has shape (1, EXPECTED_WAVEFORM_LENGTH)
287289
spectrum = self._preprocess_model(x)
288290
# y has shape (1, embedding_len)

0 commit comments

Comments
 (0)