convolution

Fitting an exponential decay using a convolution integral -

狂风中的少年 提交于 2020-01-02 18:22:07
问题 I'm fitting the following data where t: time (s), G: counts, f: impulse function: t G f -7200 4.7 0 -6300 5.17 0 -5400 4.93 0 -4500 4.38 0 -3600 4.47 0 -2700 4.4 0 -1800 3.36 0 -900 3.68 0 0 4.58 0 900 11.73 11 1800 18.23 8.25 2700 19.33 3 3600 19.04 0.5 4500 17.21 0 5400 12.98 0 6300 11.59 0 7200 9.26 0 8100 7.66 0 9000 6.59 0 9900 5.68 0 10800 5.1 0 Using the following convolution integral: And more specifically: Where: lambda_1 = 0.000431062 and lambda_2 = 0.000580525 . The code used to

ValueError: Error when checking target: expected dense_2 to have 4 dimensions, but got array with shape (7942, 1)

不想你离开。 提交于 2020-01-02 09:26:33
问题 I have been using the following functional API for an image classification task using CNN: def create_model(X_train, X_test): visible = Input(shape=(X_train.shape[0], X_train.shape[1], 1)) conv1 = Conv2D(32, kernel_size=4, activation='relu')(visible) hidden1 = Dense(10, activation='relu')(pool2) output = Dense(1, activation='sigmoid')(hidden1) model = Model(inputs = visible, outputs = output) model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) return model X

How to input mask value to Convolution1D layer

你说的曾经没有我的故事 提交于 2020-01-02 02:26:26
问题 I need to feed variable length sequences into my model. My model is Embedding + LSTM + Conv1d + Maxpooling + softmax . When I set mask_zero = True in Embedding , I fail to compile at Conv1d . How can I input mask value in Conv1d or is there another solution? 回答1: Conv1D layer does not support masking at this time. Here is an open issue on the keras repo. Depending on the task you might be able to get away with embedding the mask_value just like the other values in the sequence and apply

Strided convolution of 2D in numpy

依然范特西╮ 提交于 2020-01-01 03:25:11
问题 I tried to implement strided convolution of a 2D array using for loop i.e arr = np.array([[2,3,7,4,6,2,9], [6,6,9,8,7,4,3], [3,4,8,3,8,9,7], [7,8,3,6,6,3,4], [4,2,1,8,3,4,6], [3,2,4,1,9,8,3], [0,1,3,9,2,1,4]]) arr2 = np.array([[3,4,4], [1,0,2], [-1,0,3]]) def stride_conv(arr1,arr2,s,p): beg = 0 end = arr2.shape[0] final = [] for i in range(0,arr1.shape[0]-1,s): k = [] for j in range(0,arr1.shape[0]-1,s): k.append(np.sum(arr1[beg+i : end+i, beg+j:end+j] * (arr2))) final.append(k) return np

Convolution and Deconvolution in Python using scipy.signal

拟墨画扇 提交于 2019-12-30 11:19:28
问题 I am trying to do some (de)convolution with audio samples. I have one sample s and the same sample with some filters added on top of it s_f . Both samples are represented as numpy arrays. I want to deconvolve them in order to get an array that represents the isolated filter f . Once I do that I should be able to reproduce s_f using convolution of s and f . Here's the code: f = signal.deconvolve(s, s_f) convolved = signal.convolve(s, f) However, I get the following error on the second line:

FFT Convolution - 3x3 kernel

纵饮孤独 提交于 2019-12-30 09:49:10
问题 I have written some routines to sharpen a Grayscale image using a 3x3 kernel, -1 -1 -1 -1 9 -1 -1 -1 -1 The following code is working well in case of non-FFT (spatial-domain) convolution, but, not working in FFT-based (frequency-domain) convolution. The output image seems to be blurred. I have several problems: (1) This routine is not being able to generate desired result. It also freezes the application. public static Bitmap ApplyWithPadding(Bitmap image, Bitmap mask) { if(image.PixelFormat

Is there way to add normalization to conv2d in tensorflow

折月煮酒 提交于 2019-12-26 02:10:23
问题 in order to do pattern matching properly convolutions require normalization https://en.wikipedia.org/wiki/Cross-correlation#Normalized_cross-correlation unfortunately I can't find a way how to make input normalization for conv2d function. is it hidden in implementation? 回答1: If I'm not mis-reading that, it's in the image library in TF 1.x: tf.image.per_image_standardization https://www.tensorflow.org/api_guides/python/image By the way, that particular function is a little annoying in that it

Is there way to add normalization to conv2d in tensorflow

早过忘川 提交于 2019-12-26 02:09:34
问题 in order to do pattern matching properly convolutions require normalization https://en.wikipedia.org/wiki/Cross-correlation#Normalized_cross-correlation unfortunately I can't find a way how to make input normalization for conv2d function. is it hidden in implementation? 回答1: If I'm not mis-reading that, it's in the image library in TF 1.x: tf.image.per_image_standardization https://www.tensorflow.org/api_guides/python/image By the way, that particular function is a little annoying in that it

Is there way to add normalization to conv2d in tensorflow

て烟熏妆下的殇ゞ 提交于 2019-12-26 02:09:08
问题 in order to do pattern matching properly convolutions require normalization https://en.wikipedia.org/wiki/Cross-correlation#Normalized_cross-correlation unfortunately I can't find a way how to make input normalization for conv2d function. is it hidden in implementation? 回答1: If I'm not mis-reading that, it's in the image library in TF 1.x: tf.image.per_image_standardization https://www.tensorflow.org/api_guides/python/image By the way, that particular function is a little annoying in that it

distorted image in pgm binary file manipulation

ⅰ亾dé卋堺 提交于 2019-12-25 16:00:39
问题 I'm trying to perform convolution on a pgm image of type P5 ( binary ) with the set up below: input and output array vector<vector<char>> image(rows, vector<char>(cols, '\0')); vector<vector<char>> out(rows, vector<char>(cols, '\0')); const int SIZE = 3; Filter vector<vector<int>> filter = { { 0, -1, 0 }, { -1, 5, -1 }, { 0, -1, 0 } }; insert binary data into image array I'm reading PGM file like this: getline(infile, type); //getline(infile, comment); infile >> rows >> cols; getline(infile,