为什么这个Conv2d_Transpose/deconv2d不返回tensorflow中的原始输入? [英] Why isn't this Conv2d_Transpose / deconv2d returning the original input in tensorflow?

查看:116
本文介绍了为什么这个Conv2d_Transpose/deconv2d不返回tensorflow中的原始输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

weights = tf.placeholder("float",[5,5,1,1])
imagein = tf.placeholder("float",[1,32,32,1])
conv = tf.nn.conv2d(imagein,weights,strides=[1,1,1,1],padding="SAME")
deconv = tf.nn.conv2d_transpose(conv, weights, [1,32,32,1], [1,1,1,1],padding="SAME")


dw = np.random.rand(5,5,1,1)
noise = np.random.rand(1,32,32,1)

sess = tf.InteractiveSession()

convolved = conv.eval(feed_dict={imagein: noise, weights: dw})
deconvolved = deconv.eval(feed_dict={imagein: noise, weights: dw})

我一直在试图弄清楚conv2d_transpose,以便逆转Tensorflow中的卷积.我的理解是,反卷积"在应用正常卷积后应包含与噪声"相同的数据,然后对其进行转置,但反卷积"仅包含一些完全不同的图像.我的代码有问题吗?还是理论不正确?

I've been trying to figure out conv2d_transpose in order to reverse a convolution in Tensorflow. My understanding is that "deconvolved" should contain the same data as "noise" after applying a normal convolution and then its transpose, but "deconvolved" just contains some completely different image. Is there something wrong with my code, or is the theory incorrect?

推荐答案

它之所以被称为conv2d_transpose而不是deconv2d是有原因的:它不是去卷积.卷积不是正交变换,因此它的逆运算(反卷积)与其转置(conv2d_transpose)不同.

There's a reason it's called conv2d_transpose rather than deconv2d: it isn't deconvolution. Convolution isn't an orthogonal transformation, so it's inverse (deconvolution) isn't the same as its transpose (conv2d_transpose).

您的困惑是可以理解的:多年来,将卷积转置称为反卷积"已成为标准的神经网络实践.我很高兴我们能够在TensorFlow中将该名称固定为数学上正确的名称;这里有更多详细信息:

Your confusion is understandable: calling the transpose of convolution "deconvolution" has been standard neural network practice for years. I am happy than we were able to fix the name to be mathematically correct in TensorFlow; more details here:

https://github.com/tensorflow/tensorflow/issues/256

这篇关于为什么这个Conv2d_Transpose/deconv2d不返回tensorflow中的原始输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆