From d186216025a911bdeae2ec1e23bd120d8352d9fe Mon Sep 17 00:00:00 2001 From: Daniel Povey Date: Sat, 12 Oct 2024 17:49:44 +0800 Subject: [PATCH 1/2] Fix issue with eval mode in ActivationDropoutLinear --- egs/librispeech/ASR/zipformer/scaling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egs/librispeech/ASR/zipformer/scaling.py b/egs/librispeech/ASR/zipformer/scaling.py index 2a40b8d643..08cf2f7820 100644 --- a/egs/librispeech/ASR/zipformer/scaling.py +++ b/egs/librispeech/ASR/zipformer/scaling.py @@ -1635,7 +1635,7 @@ def __init__( self.dropout_shared_dim = dropout_shared_dim def forward(self, x: Tensor): - if torch.jit.is_scripting() or torch.jit.is_tracing(): + if torch.jit.is_scripting() or torch.jit.is_tracing() or not self.training: if self.activation == "SwooshL": x = SwooshLForward(x) elif self.activation == "SwooshR": From 27198a32ace2c7a698248030831b3f9cc3360e9a Mon Sep 17 00:00:00 2001 From: yaozengwei Date: Sat, 12 Oct 2024 19:05:23 +0800 Subject: [PATCH 2/2] change condition order --- egs/librispeech/ASR/zipformer/scaling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egs/librispeech/ASR/zipformer/scaling.py b/egs/librispeech/ASR/zipformer/scaling.py index 08cf2f7820..d345c29316 100644 --- a/egs/librispeech/ASR/zipformer/scaling.py +++ b/egs/librispeech/ASR/zipformer/scaling.py @@ -1635,7 +1635,7 @@ def __init__( self.dropout_shared_dim = dropout_shared_dim def forward(self, x: Tensor): - if torch.jit.is_scripting() or torch.jit.is_tracing() or not self.training: + if not self.training or torch.jit.is_scripting() or torch.jit.is_tracing(): if self.activation == "SwooshL": x = SwooshLForward(x) elif self.activation == "SwooshR":