espnet2.enh.layers.ncsnpp_utils.layers.ddpm_conv3x3
Less than 1 minute
espnet2.enh.layers.ncsnpp_utils.layers.ddpm_conv3x3
espnet2.enh.layers.ncsnpp_utils.layers.ddpm_conv3x3(in_planes, out_planes, stride=1, bias=True, dilation=1, init_scale=1.0, padding=1)
3x3 convolution with DDPM initialization.
This function creates a 3x3 convolutional layer initialized using the DDPM (Denoising Diffusion Probabilistic Models) method. The weights are initialized with a scale factor and the biases are set to zero.
- Parameters:
- in_planes (int) – Number of input channels.
- out_planes (int) – Number of output channels.
- stride (int , optional) – Stride of the convolution. Defaults to 1.
- bias (bool , optional) – Whether to include a bias term. Defaults to True.
- dilation (int , optional) – Dilation rate for the convolution. Defaults to 1.
- init_scale (float , optional) – Scale for weight initialization. Defaults to 1.0.
- padding (int , optional) – Padding added to both sides of the input. Defaults to 1.
- Returns: A 3x3 convolutional layer with DDPM initialization.
- Return type: nn.Conv2d
Examples
>>> conv_layer = ddpm_conv3x3(16, 32)
>>> output = conv_layer(torch.randn(1, 16, 64, 64))
>>> print(output.shape)
torch.Size([1, 32, 64, 64])
NOTE
The weight initialization is performed using the default_init function defined elsewhere in the codebase, which applies variance scaling to the weights based on the given scale factor.