Fix bug in choosing layers to drop

This commit is contained in:
Daniel Povey 2022-10-10 13:38:36 +08:00
parent 857b3735e7
commit f941991331

View File

@ -471,11 +471,11 @@ class ConformerEncoder(nn.Module):
# with their specified probs while reaching this exact target.
num_to_drop = int(tot) + int(shared_rng.random() < (tot - int(tot)))
layers = list(range(num_layers))
independent_rng.shuffle(layers)
# go through the shuffled layers until we get the required number of samples.
if num_to_drop > 0:
for layer in itertools.cycle(layers):
if independent_rng.random() < layerdrop_probs[layer]:
ans.add(layer)