From dcf8ef04e0a6fb51874f848bf0c86bd5186dd22f Mon Sep 17 00:00:00 2001 From: zxcd <228587199@qq.com> Date: Tue, 21 Feb 2023 20:41:33 +0800 Subject: [PATCH] [ASR] Remove fluid api and useless import, test=asr (#2944) * remove fluid api and useless import. * fix variable name --- paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py | 1 - paddlespeech/s2t/training/gradclip.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py b/paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py index baa7392eb..7468fdce0 100755 --- a/paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py +++ b/paddlespeech/s2t/models/wav2vec2/wav2vec2_ASR.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. from collections import defaultdict -from turtle import Turtle from typing import Dict from typing import List from typing import Tuple diff --git a/paddlespeech/s2t/training/gradclip.py b/paddlespeech/s2t/training/gradclip.py index be6fcf589..06587c749 100644 --- a/paddlespeech/s2t/training/gradclip.py +++ b/paddlespeech/s2t/training/gradclip.py @@ -56,15 +56,15 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm): if len(sum_square_list) == 0: return params_grads - global_norm_var = layers.concat(sum_square_list) + global_norm_var = paddle.concat(sum_square_list) global_norm_var = paddle.sum(global_norm_var) global_norm_var = paddle.sqrt(global_norm_var) # debug log logger.debug(f"Grad Global Norm: {float(global_norm_var)}!!!!") - max_global_norm = layers.fill_constant( - shape=[1], dtype=global_norm_var.dtype, value=self.clip_norm) + max_global_norm = paddle.full( + shape=[1], dtype=global_norm_var.dtype, fill_value=self.clip_norm) clip_var = paddle.divide( x=max_global_norm, y=paddle.maximum(x=global_norm_var, y=max_global_norm))