mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-12-11 06:55:27 +00:00
Randomize order of some modules
This commit is contained in:
parent
1be455438a
commit
c20fc3be14
@ -366,7 +366,20 @@ class ConformerEncoder(nn.Module):
|
|||||||
else:
|
else:
|
||||||
feature_mask = None
|
feature_mask = None
|
||||||
|
|
||||||
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 in indexes:
|
||||||
|
mod = self.layers[i]
|
||||||
output, attn_scores = mod(
|
output, attn_scores = mod(
|
||||||
output,
|
output,
|
||||||
pos_emb,
|
pos_emb,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user