convolution

Why does FFT accelerate the calculation involved in convolution?

坚强是说给别人听的谎言 提交于 2019-12-04 09:56:15
I am seeing a lot of literature in which they say that by using the fft one can reach a faster convolution. I know that one needs to get fft and and then ifft from the results, but I really do not understand why using the fft can make the convolution faster? FFT speeds up convolution for large enough filters, because convolution requires N multiplications (and N-1) additions for each output sample and conversely (2)N^2 operations for a block of N samples. Taking account, that one has to double the block size for FFT processing by adding zeroes, each block requires (2)*(2N)*log(2N) operations

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

Why do dilated convolutions preserve resolution?

独自空忆成欢 提交于 2019-12-04 08:39:11
问题 The animation is from here. I am wondering why the dilated convolution is claimed to preserve resolution. Apparently the input in blue is 7x7 and the output in green is 3x3. EDIT: One way to work around the resolution loss is to pad the input with roughly half the size of the current receptive field, but this essentially undermines the statement that dilated convolutions do not lose resolution, because it is the padding that preserves the resolution. To get the same output size with the input

Visualize images in intermediate layers in torch (lua)

旧巷老猫 提交于 2019-12-04 08:03:34
In the conv-nets model, I know how to visualize the filters, we can do itorch.image(model:get(1).weight) But how could I efficiently visualize the output images after the convolution? especially those images in the second or third layer in a deep neural network? Thanks. Similarly to weight, you can use: itorch.image(model:get(1).output) To visualize the weights: -- visualizing weights n = nn.SpatialConvolution(1,64,16,16) itorch.image(n.weight) To visualize the feature maps: -- initialize a simple conv layer n = nn.SpatialConvolution(1,16,12,12) -- push lena through net :) res = n:forward

Where to center the kernel when using FFTW for image convolution?

两盒软妹~` 提交于 2019-12-04 06:35:27
I am trying to use FFTW for image convolution. At first just to test if the system is working properly, I performed the fft, then the inverse fft, and could get the exact same image returned. Then a small step forward, I used the identity kernel(i.e., kernel[0][0] = 1 whereas all the other components equal 0). I took the component-wise product between the image and kernel(both in the frequency domain), then did the inverse fft. Theoretically I should be able to get the identical image back. But the result I got is very not even close to the original image. I am suspecting this has something to

Training on the merged layer in keras

混江龙づ霸主 提交于 2019-12-04 02:15:17
问题 I am implementing following this paper by Mohammad Havaei. It uses following architecture: I have modified some code from here to do so. print 'Compiling two-path model...' #local pathway modle_l=Sequential() modle_l.add(Convolution2D(64,7,7, border_mode='valid',W_regularizer=l1l2(l1=0.01, l2=0.01), input_shape=(4,33,33))) modle_l.add(Activation('relu')) modle_l.add(BatchNormalization(mode=0,axis=1)) modle_l.add(MaxPooling2D(pool_size=(2,2),strides=(1,1))) modle_l.add(Dropout(0.5)) #Add

How is convolution done with RGB channel?

半世苍凉 提交于 2019-12-03 23:49:46
Say we have a single channel image (5x5) A = [ 1 2 3 4 5 6 7 8 9 2 1 4 5 6 3 4 5 6 7 4 3 4 5 6 2 ] And a filter K (2x2) K = [ 1 1 1 1 ] An example of applying convolution (let us take the first 2x2 from A) would be 1*1 + 2*1 + 6*1 + 7*1 = 16 This is very straightforward. But let us introduce a depth factor to matrix A i.e., RGB image with 3 channels or even conv layers in a deep network (with depth = 512 maybe). How would the convolution operation be done with the same filter ? A similiar work out will be really helpful for an RGB case. They will be just the same as how you do with a single

Keras 1D CNN: How to specify dimension correctly?

与世无争的帅哥 提交于 2019-12-03 21:03:51
问题 So, what I'm trying to do is to classify between exoplanets and non exoplanets using the kepler data obtained here. The data type is a time series with the dimension of ( num_of_samples,3197 ). I figured out that this can be done by using 1D Convolutional Layer in Keras. But I keep messing the dimensions and get the following error Error when checking model input: expected conv1d_1_input to have shape (None, 3197, 1) but got array with shape (1, 570, 3197) So, the questions are: 1.Does the

How to find wrong prediction cases in test set (CNNs using Keras)

寵の児 提交于 2019-12-03 17:17:58
问题 I'm using MNIST example with 60000 training image and 10000 testing image. How do I find which of the 10000 testing image that has an incorrect classification/prediction? 回答1: Simply use model.predict_classes() and compare the output with true labes. i.e: incorrects = np.nonzero(model.predict_class(X_test).reshape((-1,)) != y_test) to get indices of incorrect predictions 来源: https://stackoverflow.com/questions/39300880/how-to-find-wrong-prediction-cases-in-test-set-cnns-using-keras