init 1st conv module to smaller variance

This commit is contained in:
Daniel Povey 2022-03-11 16:37:17 +08:00
parent bcf417fce2
commit bec33e6855
2 changed files with 9 additions and 1 deletions

View File

@ -59,6 +59,14 @@ class Conv2dSubsampling(nn.Module):
) )
self.out = nn.Linear(odim * (((idim - 1) // 2 - 1) // 2), odim) self.out = nn.Linear(odim * (((idim - 1) // 2 - 1) // 2), odim)
self.out_norm = BasicNorm(odim) self.out_norm = BasicNorm(odim)
self._reset_parameters()
def _reset_parameters(self):
# init weights with smaller than default variance, because otherwise
# they learn too slowly in relative terms (assuming we're training with adam).
nn.init.normal_(self.conv[0].weight, std=0.05)
nn.init.constant_(self.conv[0].bias, 0.0)
def forward(self, x: torch.Tensor) -> torch.Tensor: def forward(self, x: torch.Tensor) -> torch.Tensor:
"""Subsample x. """Subsample x.

View File

@ -110,7 +110,7 @@ def get_parser():
parser.add_argument( parser.add_argument(
"--exp-dir", "--exp-dir",
type=str, type=str,
default="transducer_stateless/specaugmod_baseline_randcombine1_expscale3_brelu2swish2_0.1_bnorm2ma0.5_pbs", default="transducer_stateless/randcombine1_expscale3_brelu2swish2_0.1_bnorm2ma0.5_pbs_cinit",
help="""The experiment dir. help="""The experiment dir.
It specifies the directory where all training related It specifies the directory where all training related
files, e.g., checkpoints, log, etc, are saved files, e.g., checkpoints, log, etc, are saved