From 0c4e55c1c1cc2e76adf3828d20b98df5f585684b Mon Sep 17 00:00:00 2001 From: Meysam Moqaddam <65253484+MeysamMoghaddam@users.noreply.github.com> Date: Mon, 31 Mar 2025 08:12:44 +0330 Subject: [PATCH] Update transformer_asr.py Add small epsilon (1e-10) to stddevs to prevent division by zero Modified the normalization step by adding a small constant to stddevs to avoid potential division by zero errors when standard deviation is zero. --- examples/audio/transformer_asr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/audio/transformer_asr.py b/examples/audio/transformer_asr.py index f7b1d7130e..feddad3bd2 100644 --- a/examples/audio/transformer_asr.py +++ b/examples/audio/transformer_asr.py @@ -372,7 +372,7 @@ def path_to_audio(path): # normalisation means = tf.math.reduce_mean(x, 1, keepdims=True) stddevs = tf.math.reduce_std(x, 1, keepdims=True) - x = (x - means) / stddevs + x = (x - means) / (stddevs + 1e-10) audio_len = tf.shape(x)[0] # padding to 10 seconds pad_len = 2754