Merge branch 'scaled_adam_exp58' into scaled_adam_exp67

This commit is contained in:
Daniel Povey 2022-10-06 14:27:12 +08:00
commit 99d17d13cf

View File

@ -343,7 +343,20 @@ class ConformerEncoder(nn.Module):
output = output * feature_mask
for i, mod in enumerate(self.layers):
num_layers = len(self.layers)
indexes = list(range(num_layers))
if self.training:
num_to_swap = int((num_layers - 1) * 0.1)
for i in range(num_to_swap):
j = random.randint(0, num_layers - 2)
a,b = indexes[j], indexes[j+1]
indexes[j] = b
indexes[j+1] = a
for i,j in enumerate(indexes):
mod = self.layers[j]
output, attn_scores = mod(
output,
pos_emb,