espnet2.gan_codec.hificodec.module.init_weights
Less than 1 minute
espnet2.gan_codec.hificodec.module.init_weights
espnet2.gan_codec.hificodec.module.init_weights(m, mean=0.0, std=0.01)
Initialize weights for convolutional layers.
This function applies a normal distribution to the weights of convolutional layers in a given module. It sets the weights to have a mean of mean and a standard deviation of std.
- Parameters:
- m (torch.nn.Module) – The module whose weights are to be initialized.
- mean (float , optional) – The mean of the normal distribution. Defaults to 0.0.
- std (float , optional) – The standard deviation of the normal distribution. Defaults to 0.01.
NOTE
This function specifically checks if the module is of a convolutional type (i.e., classes that contain “Conv” in their name) before applying the weight initialization.
Examples
>>> model = nn.Sequential(
... nn.Conv2d(1, 20, 5),
... nn.Conv2d(20, 64, 5)
... )
>>> model.apply(init_weights)