espnet2.gan_codec.shared.discriminator.msstft_conv.NormConvTranspose2d
espnet2.gan_codec.shared.discriminator.msstft_conv.NormConvTranspose2d
class espnet2.gan_codec.shared.discriminator.msstft_conv.NormConvTranspose2d(*args, norm: str = 'none', norm_kwargs: Dict[str, Any] = {}, **kwargs)
Bases: Module
Wrapper around ConvTranspose2d and normalization applied to this conv to provide
a uniform interface across normalization approaches.
This class extends the PyTorch nn.Module to include a transposed convolution layer with normalization. It allows for different normalization techniques to be applied seamlessly during the forward pass.
convtr
The transposed convolution layer.
- Type: nn.ConvTranspose2d
norm
The normalization layer applied after the transposed convolution.
Type: nn.Module
Parameters:
- *args – Variable length argument list for the ConvTranspose2d constructor.
- norm (str) – The type of normalization to apply. Default is “none”.
- norm_kwargs (Dict *[*str , Any ]) – Additional keyword arguments for the normalization layer.
- **kwargs – Variable length keyword arguments for the ConvTranspose2d constructor.
Returns: The output tensor after applying the transposed convolution and normalization.
Return type: Tensor
####### Examples
>>> layer = NormConvTranspose2d(in_channels=3, out_channels=2, kernel_size=3)
>>> input_tensor = torch.randn(1, 3, 10, 10)
>>> output_tensor = layer(input_tensor)
>>> print(output_tensor.shape)
torch.Size([1, 2, 12, 12])
NOTE
This class relies on external functions apply_parametrization_norm and get_norm_module to handle the application of normalization.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)
Wrapper around ConvTranspose2d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
This class allows for the use of different normalization techniques alongside transposed convolution operations, enabling flexible architecture designs for deep learning models.
convtr
The transposed convolution layer.
- Type: nn.ConvTranspose2d
norm
The normalization layer applied after the transposed convolution.
Type: nn.Module
Parameters:
- *args – Variable length argument list for ConvTranspose2d.
- norm (str) – The type of normalization to apply. Default is “none”.
- norm_kwargs (Dict *[*str , Any ]) – Additional keyword arguments for the normalization layer.
- **kwargs – Variable length keyword arguments for ConvTranspose2d.
Returns: The output tensor after applying the transposed convolution and normalization.
Return type: Tensor
####### Examples
>>> layer = NormConvTranspose2d(in_channels=16, out_channels=33,
... kernel_size=3, norm='batch')
>>> input_tensor = torch.randn(1, 16, 10, 10)
>>> output_tensor = layer(input_tensor)
>>> output_tensor.shape
torch.Size([1, 33, 12, 12])
NOTE
Ensure that the input tensor shape is compatible with the ConvTranspose2d layer’s requirements.
- Raises:ValueError – If the provided normalization type is not supported.