Questions tagged [convolution]

A mathematical operation that combines two signals to generate a third signal. Convolution often arises in audio processing (e.g., filtering, reverb) and image processing (e.g., blurring, edge detection).

Convolution takes two signals and combines them to generate a third signal. For 1-D signals, the operation can be thought of as sliding the time-reverse of one signal along the other, and at each time step, taking the integral of the product of the signals (see wikipedia). The convolution operation describes the response of linear time-invariant systems to common input signals. Therefore, it commonly occurs in digital signal processing (DSP) contexts. Audio and image processing are two very common application areas for convolution.

A simple implementation for convolving two discrete time signals requires M*N multiply-add operations, where M and N are the lengths of the two signals. However, by taking advantage of the fact that convolution in the time domain is equivalent to multiplication in the frequency domain, and that transforming between domains can be implemented with O(N*log N) operations, convolution can be sped up. See here for more details.


Related tags

2052 questions
0
votes
1 answer

How to actually apply a Conv2d filter in Pytorch

I’m new to Python and trying to do some manipulations with filters in PyTorch. I’m struggling re how to apply a Conv2d. I’ve got the following code which creates a 3x3 moving average filter: resized_image4D = np.reshape(image_noisy, (1, 1,…
0
votes
0 answers

#MAC operations in Convolution layer

The formula for the number of MAC operations in CONV is given by Filter_height * filter_width * In_channels * out_height * out_width * out_channels. I understand that multiplication and accumulation happens together every cycle. Does this formula…
0
votes
2 answers

Why does nn.Conv1d work on 2d feature [b, c, h, w]?

I am wondering why conv1d works on 2d feature(batch, channel, height, width). An nn.Conv1d(channel, channel, kernel_size=(1,1)) works when I put 2d feature, but gives different result from nn.Conv2d(channel, channel, kernel_size=1). I want to know…
0
votes
0 answers

Pytorch: convolution with non-constant kernel

Is there a built-in function in any torch-compatible library that allows to consider convolutions (in 2 dimensions) with kernels that depend on the coordinates of the input. More precisely, I would like a function such that: the input has size…
ZZZ
  • 21
  • 4
0
votes
1 answer

No result obtained from calculation

I am trying to convolve an image using CUDA, but I cannot get a result. cuda-gdb does not work properly on my system so I cannot tell what is happening inside the CUDA kernel. The CUDA kernel I am using is the…
0
votes
1 answer

Convolution on Python

So I suppose to calculate the convolution between Fourier Transformed image and the mask. from scipy import fftpack import numpy as np import imageio from PIL import Image, ImageDraw import cv2 import matplotlib.pyplot as plt import math from…
0
votes
1 answer

which value is used for padding in tensorflow convolution?

In PyTorch, there are two choices for padding_mode when using convolution: zeros and circular. However, I cannot find a similar parameter in the docs of TensorFlow. In addition, I find that TensorFlow is not using 0 as the value to pad the…
f-sky
  • 41
  • 3
0
votes
1 answer

Fast convolution algorithm have different outputs compared to regular convolution algorithm?

I was trying to speed up a forward pass in a convolutional layer by using a technique of converting my image data to a column vector and essentially converting my convolution problem into a matrix multiplication problem. [idea from…
0
votes
2 answers

1d Fourier convolution python

Problem I want to write a very simple 1d convolution using Fourier transforms. My code does not give the expected result. Code import numpy as np import scipy def fftconvolve(x, y): ''' Perso method to do FFT convolution''' fftx =…
paulo
  • 65
  • 6
0
votes
0 answers

Difference between numpy.convolve and scipy.ndimage.convolve1d?

What is the difference between the algorithms underlying numpy.convolve and scipy.ndimage.convolve1d? Are there are other equivalent/similar functions in Python? Which is most appropriate for associatively implementing multivariate convolutions…
develarist
  • 1,224
  • 1
  • 13
  • 34
0
votes
1 answer

Convolution of more than 2 probability distributions in Python

numpy.convolve(a, v, mode='full') only admits two inputs: a(N,) array_like First one-dimensional input array. v(M,) array_like Second one-dimensional input array. How can I instead calculate the convolution of more than 2 probability distributions…
develarist
  • 1,224
  • 1
  • 13
  • 34
0
votes
1 answer

Question on the kernel dimensions for convolutions on mel filter bank features

I am currently trying to understand the following paper: https://arxiv.org/pdf/1703.08581.pdf. I am struggling to understand a part about how a convolution is performed on an input of log mel filterbank features: We train seq2seq models for both…
0
votes
1 answer

Pytorch: convolve a sample with a specific filter

Given a batch of samples, I would like to convolve each of them with different filters. I have implemented the idea with keras and the code works: import keras.backend as K def single_conv(tupl): inp, kernel = tupl outputs = K.conv1d(inp,…
zhf061
  • 311
  • 2
  • 7
0
votes
2 answers

Smoothing a curve with many peaks with Gaussian

I have spectroscopy data with some very sharp peaks as seen in blue curve. I would like to make the peaks a bit more smooth like the orange curve in the plot. I thought the easiest way to do this is to convolve my data points with Gaussians. I know…
beliz
  • 402
  • 1
  • 5
  • 25
0
votes
1 answer

why convolution of x and y is different ifft(fft(x)xfft(y))?

I know that convolution of x and y in time domain is equal to fft(x) times by fft(y) in frequency domain. so I tried simple example using matlab as below. xn=[1,2,3,4]; yn=[4,3,2,1]; zn=conv(xn,yn); znr=ifft(fft(xn).*fft(yn)); and I got the result…
agile
  • 77
  • 5