From 7920fa7726f6faf4fb783460750fa2756f9f31b6 Mon Sep 17 00:00:00 2001 From: Daniel Povey Date: Mon, 12 Dec 2022 23:29:42 +0800 Subject: [PATCH] Add out_balancer for attention_squeeze, similar to nonlin_attention_module. --- .../ASR/pruned_transducer_stateless7/zipformer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/egs/librispeech/ASR/pruned_transducer_stateless7/zipformer.py b/egs/librispeech/ASR/pruned_transducer_stateless7/zipformer.py index 65c2ffb0d..a122a112f 100644 --- a/egs/librispeech/ASR/pruned_transducer_stateless7/zipformer.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless7/zipformer.py @@ -1403,6 +1403,13 @@ class AttentionSqueeze(nn.Module): prob=_aux_grad_prob_out(), bias=False, initial_scale=0.05) + self.out_balancer = ActivationBalancer( + channels, channel_dim=-1, + min_positive=0.4, max_positive=0.5, + min_abs=ScheduledFloat((0.0, 0.002), (8000.0, 0.02), (20000.0, 0.01)), + ) + + def forward(self, x: Tensor, attn_weights: Tensor):