CNTK:如何定义 UpSampling2D

CNTK: How to define UpSampling2D

我想知道如何在CNTK 中实现UpSampling2D。我在 API.

中找不到这样的图层

UpSampling2D是池化层的相反操作,通过重复数据的行和列来扩展数据。 UpSampling2D.

的 keras/tensorflow API

通过查看 tensorflow code, they use backend.resize_images operation, but I cannot find resize operation in CNTK API

答案 1(来自 Frank)

答案 2(来自 David)

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)