I'd like to upsample one layer with size of (w,h,channels) to size of (w',h',channels), but the Upsample2D layer just can upsample to the double size.
Anybody could tell me how do any size upsampling?
The Keras UpSample2D
can upsample to different sizes, not just double size. From the Keras docs we can see this is indicated for such layer:
keras.layers.UpSampling2D(size=(2, 2), data_format=None)
Upsampling layer for 2D inputs.
Repeats the rows and columns of the data by size[0] and size[1] respectively.
The default size
value is indeed (2,2)
, so in that case your upsampling will be double. By specifying the size you desire you can manage to upsample to different sizes according to your needs. So, if you want an upsample factor of say, 3 then you should use size=(3,3)
, etc.
As alternatives, you can also define your own custom layers if you want something really specific to your case. For example, here is a Github issue about creating custom pooling function (opposite of upsampling layers, so easily comparable), which could help you in case you needed such custom layer.
size=(5,5)
. Glad it helped :)
Commented
Nov 16, 2017 at 0:57