python – CNTK:如何定义UpSampling2D

我想知道如何在CNTK中实现UpSampling2D.我在 API找不到这样的图层.

UpSampling2D是池化图层的相反操作,通过重复数据的行和列来扩展数据.这是UpSampling2D的keras / tensorflow API.

通过查看tensorflow code,他们使用backend.resize_images操作,但我也无法在CNTK API中找到调整大小操作.

《python – CNTK:如何定义UpSampling2D》

答案1(来自Frank)

《python – CNTK:如何定义UpSampling2D》

答案2(来自大卫)

《python – CNTK:如何定义UpSampling2D》

Picture from Quora: How do fully convolutional networks upsample their coarse output?

最佳答案 它可以从重塑和拼接的基本操作组装,例如,

>>> 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)
点赞