espnet2.gan_tts.wavenet.residual_block.Conv1d
espnet2.gan_tts.wavenet.residual_block.Conv1d
class espnet2.gan_tts.wavenet.residual_block.Conv1d(*args, **kwargs)
Bases: Conv1d
Conv1d module with customized initialization.
This class is a subclass of torch.nn.Conv1d and provides a customized initialization for the convolutional layer weights using Kaiming normal initialization and sets the bias to zero if it exists.
weight
The learnable weights of the module of shape (out_channels, in_channels, kernel_size).
- Type: Tensor
bias
The learnable bias of the module of shape (out_channels).
Type: Tensor, optional
Parameters:
- *args – Variable length argument list for the parent torch.nn.Conv1d.
- **kwargs – Arbitrary keyword arguments for the parent torch.nn.Conv1d.
####### Examples
>>> conv = Conv1d(in_channels=3, out_channels=2, kernel_size=5)
>>> print(conv)
Initialize Conv1d module.
reset_parameters()
Reset parameters of the Conv1d layer.
This method initializes the weight of the convolutional layer using the Kaiming normal initialization, which is suitable for layers followed by a ReLU activation function. If the layer has a bias term, it is set to zero.
weight
The weight of the convolutional layer.
- Type: torch.Tensor
bias
The bias of the convolutional layer, if applicable.
Type: Optional[torch.Tensor]
Raises:ValueError – If the weight tensor is not initialized properly.
####### Examples
>>> conv_layer = Conv1d(in_channels=1, out_channels=2, kernel_size=3)
>>> conv_layer.reset_parameters()
>>> print(conv_layer.weight)
tensor([[...], ...]) # Initialized weights
>>> print(conv_layer.bias)
tensor([0.]) # Bias initialized to zero