【问题标题】:Create a layer that add a zero-channel to my tensor创建一个向我的张量添加零通道的层
【发布时间】:2019-03-27 23:49:30
【问题描述】:

我正在研究 DCSCN(一种用于图像超分辨率的神经网络),我想根据 Alex Kendall 和 Yarin Gal 方法评估不确定性,在“我们在贝叶斯深度学习中需要哪些不确定性来实现计算机视觉?”使用 Keras。

为此,我需要一个具有 (?,n,m,3) 形状张量并返回 (?,n,m,4) 和 (?,n,m,-1) 的张量的层用零。

我试过这个功能:

def AddChan(**kwargs):

    def layer(x):
        input_shape = K.int_shape(x)
        output_shape = (input_shape[0], input_shape[1],input_shape[2],1)
        z = K.zeros(output_shape)
        res = K.concatenate([x, z], axis=-1)
        return res
    return Lambda(layer, **kwargs)

哪个提高:

Expected int32, got None of type '_Message' instead.

我认为这是因为 input_shape[0] 是动态的,但我没有看到其他方式来获得我想要的东西。

有人有想法吗?

谢谢!

【问题讨论】:

    标签: python image keras layer


    【解决方案1】:

    尝试将K.int_shape 替换为K.shape 以获得张量或变量的符号形状,而不是整数形状。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      相关资源
      最近更新 更多