espnet2.enh.layers.ncsnpp_utils.up_or_down_sampling.upsample_2d
Less than 1 minute
espnet2.enh.layers.ncsnpp_utils.up_or_down_sampling.upsample_2d
espnet2.enh.layers.ncsnpp_utils.up_or_down_sampling.upsample_2d(x, k=None, factor=2, gain=1)
Upsample a batch of 2D images with the given filter.
Accepts a batch of 2D images of the shape [N, C, H, W] or [N, H, W, C] and upsamples each image with the given filter. The filter is normalized so that if the input pixels are constant, they will be scaled by the specified gain. Pixels outside the image are assumed to be zero, and the filter is padded with zeros so that its shape is a multiple of the upsampling factor. :param x: Input tensor of the shape [N, C, H, W] or
`
[N, H, W,
C]`.
- Parameters:
- k – FIR filter of the shape [firH, firW] or [firN] (separable). The default is [1] * factor, which corresponds to nearest-neighbor upsampling.
- factor – Integer upsampling factor (default: 2).
- gain – Scaling factor for signal magnitude (default: 1.0).
- Returns: Tensor of the shape [N, C, H * factor, W * factor]