【问题标题】:Tensorflow: Get the same tensor after a series of convolution and deconvolutionTensorflow:经过一系列卷积和反卷积后得到相同的张量
【发布时间】:2019-04-02 22:12:24
【问题描述】:

我想知道是否有可能在通过卷积然后反卷积滤波器传播后得到相同的张量。例如:

random_image = np.random.rand(1, 6, 6, 3)
input_image = tf.placeholder(shape=[1, 6, 6, 3], dtype=tf.float32)
conv = tf.layers.conv2d(input_image, filters=6, kernel_size=[3, 3], strides=(1, 1), data_format="channels_last")
deconv = tf.layers.conv2d_transpose(conv, filters=3, kernel_size=[3, 3], strides=(1, 1), data_format="channels_last")
sess = tf.Session()
sess.run(tf.global_variables_initializer())
print(random_image)
# Get an output which will be same as:
print(sess.run(deconv, feed_dict={input_image: random_image}))

也就是说,如果生成的random_image向量例如是:[1,2,3,4,5],经过卷积和反卷积后deconv向量就是[1,2,3,4,5]

但是,我无法让它工作。

期待您的回答!

【问题讨论】:

  • 定义“相同”。您是在追求完全相同的数组值还是某种视觉相似性?也许您在实际图像上进行测试并分享结果?
  • 我的意思是随机图像向量为:[1,2,3,4,5],经过卷积和反卷积后的输出为:[1,2,3,4,5]。我还根据您的评论更新了问题。
  • 有可能获得某种程度的视觉相似性,但数学上的相等性,我猜不是。看看stackoverflow.com/questions/37890989/…
  • 感谢您的帮助!这就是我需要的澄清。请随时发布答案,以便我接受它是正确的。

标签: tensorflow conv-neural-network deconvolution


【解决方案1】:

例如,通过使用 VarianceScaling 初始化,可以获得某种程度的视觉相似性。甚至使用完全自定义的初始化程序。但是转置卷积在数学上不是反卷积。所以你不能用conv2d_transpose 得到数学相等。

看看Why isn't this Conv2d_Transpose / deconv2d returning the original input in tensorflow?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多