espnet2.enh.layers.ncsnpp_utils.layers.ncsn_conv3x3
Less than 1 minute
espnet2.enh.layers.ncsnpp_utils.layers.ncsn_conv3x3
espnet2.enh.layers.ncsnpp_utils.layers.ncsn_conv3x3(in_planes, out_planes, stride=1, bias=True, dilation=1, init_scale=1.0, padding=1)
3x3 convolution with PyTorch initialization. Same as NCSNv1/NCSNv2.
This function creates a 3x3 convolutional layer with the specified input and output channels. The layer is initialized using the given initialization scale. If the initialization scale is set to zero, a very small value is used to avoid zero initialization.
- Parameters:
- in_planes (int) – Number of input channels.
- out_planes (int) – Number of output channels.
- stride (int , optional) – Stride of the convolution. Default is 1.
- bias (bool , optional) – If True, adds a learnable bias to the output. Default is True.
- dilation (int , optional) – Spacing between kernel elements. Default is 1.
- init_scale (float , optional) – Scale for initializing the weights. Default is 1.0.
- padding (int , optional) – Padding added to both sides of the input. Default is 1.
- Returns: A 3x3 convolutional layer with the specified parameters.
- Return type: nn.Conv2d
Examples
>>> conv_layer = ncsn_conv3x3(in_planes=64, out_planes=128)
>>> output = conv_layer(torch.randn(1, 64, 32, 32))
>>> output.shape
torch.Size([1, 128, 32, 32])
NOTE
The convolution is designed to match the architecture of NCSNv1 and NCSNv2.