deconvolution

How can I implement deconvolution layer for a CNN in numpy?

拟墨画扇 提交于 2019-12-07 07:07:14
问题 I try to implement Deconvolution layer for a Convolution Network. What I mean by deconvolution is that suppose I have 3x227x227 input image to a layer with filters in size 3x11x11 and stride 4. Hence the resulting feature map has size 55x55 . What I try to do is to apply the reverse operation where I project 55x55 feature map to again 3x227x227 image. Basically each value on 55x55 feature map is weighted by 3x11x11 filters and projected to image space and overlapping regions due to stride is

How can I give a variable batch_dim in output_shape argument of deconv2d in tensorflow?

元气小坏坏 提交于 2019-12-06 12:14:43
问题 I am trying to use the tf.nn.deconv2d() op on a variable-sized batch of data. However, it appears that I need to set the output_shape argument as follows: tf.nn.deconv2d(x, filter, output_shape=[12, 24, 24, 5], strides=[1, 2, 2, 1], padding="SAME") Why does tf.nn.deconv2d() take a fixed output_shape ? Is there any way to specify a variable batch dimension? What happens if the input batch size varies? 回答1: N.B. tf.nn.deconv2d() will be called tf.nn.conv2d_transpose() in the next release of

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

烈酒焚心 提交于 2019-12-06 06:11:39
问题 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}) I've been trying to figure

deblurring image by deconvolution using opencv

你。 提交于 2019-12-05 04:07:17
问题 I have two images o1 & o2 , and I have blurred the two images using the same Gaussian blurring kernel. Then I have found kernel k1 = DFT(b1) / DFT (o1) , where b1 is the image obtained by blurring o1 . I have used this kernal ( k1 ) to perform deconvolution on b2 , where b2 is obtained by blurring o2 . But deblurred output is not correct (the output image does not have any relation with original) what is the problem in my code ? int main(int argc, char** argv) { Mat orig1 = imread(argv[1], 0)

What are the constraints on the divisor argument of scipy.signal.deconvolve to ensure numerical stability?

不打扰是莪最后的温柔 提交于 2019-12-04 14:31:47
Here is my problem: I am going to process data coming from a system for which I will have a good idea of the impulse response. Having used Python for some basic scripting before, I am getting to know the scipy.signal.convolve and scipy.signal.deconvolve functions. In order to get some confidence in my final solution, I would like to understand their requirements and limitations. I used the following test: 1. I built a basic signal made of two Gaussians. 2. I built a Gaussian impulse response. 3. I convolved my initial signal with this impulse response. 4. I deconvolved this convolved signal. 5

How is using im2col operation in convolutional nets more efficient?

自古美人都是妖i 提交于 2019-12-04 12:07:34
问题 I am trying to implement a convolutional neural netwrok and I don't understand why using im2col operation is more efficient. It basically stores the input to be multiplied by filter in separate columns. But why shouldn't loops be used directly to calculate convolution instead of first performing im2col ? 回答1: Well, you are thinking in the right way, In Alex Net almost 95% of the GPU time and 89% on CPU time is spent on the Convolutional Layer and Fully Connected Layer. The Convolutional Layer

CNN: input stride vs. output stride

泄露秘密 提交于 2019-12-04 09:31:05
In the paper 'Fully Convolutional Networks for Semantic Segmentation' the author distinguishes between input stride and output stride in the context of deconvolution. How do these terms differ from each other? Input stride is the stride of the filter . How much you shift the filter in the output . Output Stride this is actually a nominal value . We get feature map in a CNN after doing several convolution , max-pooling operations . Let's say our input image is 224 * 224 and our final feature map is 7*7 . Then we say our output stride is : 224/7 = 32 (Approximate of what happened to the image

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

笑着哭i 提交于 2019-12-04 09:22:14
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}) I've been trying to figure out conv2d_transpose in order to reverse a convolution in Tensorflow. My understanding is that

deblurring image by deconvolution using opencv

眉间皱痕 提交于 2019-12-03 20:24:16
I have two images o1 & o2 , and I have blurred the two images using the same Gaussian blurring kernel. Then I have found kernel k1 = DFT(b1) / DFT (o1) , where b1 is the image obtained by blurring o1 . I have used this kernal ( k1 ) to perform deconvolution on b2 , where b2 is obtained by blurring o2 . But deblurred output is not correct (the output image does not have any relation with original) what is the problem in my code ? int main(int argc, char** argv) { Mat orig1 = imread(argv[1], 0); Mat orig2 = imread(argv[2], 0); Mat blur1, blur2; GaussianBlur(orig1, blur1, Size(11, 11), 0, 0 );

How is using im2col operation in convolutional nets more efficient?

一曲冷凌霜 提交于 2019-12-03 07:51:38
I am trying to implement a convolutional neural netwrok and I don't understand why using im2col operation is more efficient. It basically stores the input to be multiplied by filter in separate columns. But why shouldn't loops be used directly to calculate convolution instead of first performing im2col ? Well, you are thinking in the right way, In Alex Net almost 95% of the GPU time and 89% on CPU time is spent on the Convolutional Layer and Fully Connected Layer. The Convolutional Layer and Fully Connected Layer are implemented using GEMM that stands for General Matrix to Matrix