espnet2.gan_tts.parallel_wavegan.upsample.Conv2d
espnet2.gan_tts.parallel_wavegan.upsample.Conv2d
class espnet2.gan_tts.parallel_wavegan.upsample.Conv2d(*args, **kwargs)
Bases: Conv2d
Conv2d module with customized initialization.
This module extends the standard PyTorch Conv2d layer to include a custom parameter initialization method. The weights are initialized to a constant value based on the kernel size, and the bias (if present) is initialized to zero.
weight
The learnable weights of the module of shape (out_channels, in_channels, kernel_height, kernel_width).
- Type: torch.Tensor
bias
The learnable bias of the module, of shape (out_channels,) if bias is enabled, otherwise None.
Type: torch.Tensor or None
Parameters:
- *args – Variable length argument list for Conv2d.
- **kwargs – Keyword arguments for Conv2d.
reset_parameters()
Resets the parameters of the Conv2d layer.
####### Examples
>>> conv_layer = Conv2d(in_channels=3, out_channels=16, kernel_size=3)
>>> print(conv_layer.weight) # Check initialized weights
>>> print(conv_layer.bias) # Check initialized bias
Initialize Conv2d module.
reset_parameters()
Reset parameters.
This method initializes the weights of the Conv2d module to a constant value based on the kernel size, and sets the bias to zero if it exists. This can be useful to reset the model’s state before training or fine-tuning.
The weights are filled with the value 1.0 / np.prod(self.kernel_size), which ensures that the sum of the weights is normalized to 1 across the kernel.
NOTE
This method is typically called during the initialization of the model or before training to ensure that the weights are set to a known state.
####### Examples
>>> conv_layer = Conv2d(1, 1, kernel_size=(3, 3))
>>> conv_layer.reset_parameters()
>>> print(conv_layer.weight.data) # Should print the initialized weights
- Raises:None –