Hi, this is how I use UpSampling - for nearest interpolation. I recall there was an issue - I had trouble when I was trying to do bilinear.
class UpSample(HybridBlock):
def __init__(self,_nfilters, factor = 2, _norm_type='BatchNorm', **kwards):
HybridBlock.__init__(self,**kwards)
self.factor = factor
self.nfilters = _nfilters // self.factor
with self.name_scope():
self.convup_normed = Conv2DNormed(self.nfilters,
kernel_size = (3,3), # you can choose to use (1,1), but then nearby pixels will again have same value for the same channel, for interpolation "nearest".
padding = 1,
_norm_type = _norm_type,
prefix="_convdn_")
def hybrid_forward(self,F,_xl):
x = F.UpSampling(_xl, scale=self.factor, sample_type='nearest')
x = self.convup_normed(x)
return x
in this example I first upsample, (double the size) and then I apply a convolution operator to “smooth” out the upscaling. I am using it in place of transposed convolution.
edit There is also a new operator (at least I just saw it) in mxnet.F.contrib.BilinearResize2D, however you need to supply the new height and width (F can be either Symbol or NDArray).