我想知道如何在CNTK中实现UpSampling2D。我在API中找不到这样的图层。
UpSampling2D是池化图层的相反操作,通过重复数据的行和列来扩展数据。这是UpSampling2D的keras / tensorflow API。
通过查看tensorflow code,他们使用backend.resize_images
操作,但我无法在CNTK API中找到调整大小操作。
Picture from Quora: How do fully convolutional networks upsample their coarse output?
答案 0 :(得分:2)
它可以通过重塑和拼接的基本操作进行组装,例如
>>> x = Input((3, 480, 640))
>>> xr = reshape(x, (3, 480, 1, 640, 1))
>>> xr.shape
(3, 480, 1, 640, 1)
>>> xx = splice(xr, xr, axis=-1) # axis=-1 refers to the last axis
>>> xx.shape
(3, 480, 1, 640, 2)
>>> xy = splice(xx, xx, axis=-3) # axis=-3 refers to the middle axis
>>> xy.shape
(3, 480, 2, 640, 2)
>>> r = reshape(xy, (3, 480*2, 640*2))
>>> r.shape
(3, 960, 1280)