【问题标题】:CNTK: How to define UpSampling2DCNTK:如何定义 UpSampling2D
【发布时间】:2017-03-28 20:48:25
【问题描述】:

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

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

通过查看tensorflow code,他们使用backend.resize_images 操作,但我在CNTK API 中也找不到resize 操作。

答案 1(来自弗兰克)

答案 2(来自大卫)

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

【问题讨论】:

    标签: python deep-learning keras cntk


    【解决方案1】:

    它可以从基本的整形和拼接操作组装起来,例如

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

    【讨论】:

    • 实际上,使用 CNTK/Python 2.0 版(在 Azure Notebook 上),我收到此错误:TypeError: splice() got multiple values for argument 'axis'。需要这样做 C.splice((xr, xr), axis=-1)
    • @Frank Seide 我在 CNTK C# 中试过这个。尺寸翻了一番,但图像内容没有上采样。相反,它只是彼此相邻的原始图像的 4 倍。拼接如何对图片内容进行上采样?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-28
    • 1970-01-01
    相关资源
    最近更新 更多