Answers.Body: <p>I think this should work for you:
  <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.correlate.html" rel="nofollow noreferrer">scipy.signal.correlate | SciPy</a></p>
  <p>I used it myself while I was writing a CNN in numpy.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-10T21:29:54.297Z
Answers.Text: Mm, it doesn't seem optimal, but I don't know a better way that just to correlate and take elements with the corresponding step.
Answers.UserDisplayName: Michał Słodki
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-10T21:30:41.957Z
Answers.Text: Anyway, thanks for good answer. I'll use it in my code.
Answers.UserDisplayName: TheFnafException
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-10T21:32:27.057Z
Answers.Text: Given that the OP apparently wants to implement the correlation/convolution from scratch, then maybe you should spend some words to explain how that can be conceptually done. By the way, welcome to AI SE! Have a look at our on-topic page https://ai.stackexchange.com/help/on-topic to know more about the type of question we are looking for.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-10T21:14:56.453Z
Answers.LastActivityDate: 2021-05-08T17:02:50.733Z
Answers.LastEditDate: 2021-05-08T17:02:50.733Z
Answers.UserDisplayName: Michał Słodki
Answers.Body: <p>I think what you need to use is 3D convolution operation. Your data is 3D, width, height, and num_channels. Your data is similar to color images with RGB channels. However, since you are trying to consider the correlation amongst channels 2D convolution will not work for you. You can use 3D convolution which is available to use with deep learning tools such as Tensorflow.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-16T11:13:07.743Z
Answers.Text: P.S. My data is 4D: [ batch_size, width, height, and num_channels ].
Answers.UserDisplayName: TheFnafException
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-16T11:13:16.693Z
Answers.Text: Yes, my images are RGB
Answers.UserDisplayName: TheFnafException
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-16T14:12:54.510Z
Answers.Text: What is the 4 dimensions in your data, i only see 3, batch_size is not a dimension of data, isnt it the batch size of the input of the neural network or is it somthing else.
Answers.UserDisplayName: gihan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-15T05:13:15.153Z
Answers.LastActivityDate: 2020-09-15T05:13:15.153Z
Answers.UserDisplayName: gihan
Body: <p>I want to create a CNN in Python, specifically, only with NumPy, if possible. For optimizing the time of convolution (actually correlation) in the network, I wanna try to use FFT-based convolution. The data that needs to be convoluted (correlated) is a 4D image tensor with shape <code>[batch_size, width, height, channels]</code> and 4D filter tensor <code>[filter_width, filter_height, in_channel, out_channel]</code>. I read a lot of articles about FFT-based convolution, but they aren't doing it in my way. Thus, I need your help.</p>
  <p>How could I fft-convolve a 4D image and a 4D filter with stride?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-10T21:23:09.490Z
Comments.Text: Hello. It's not clear what your question is. Please, explicitly ask a specific question about your problem.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-10T21:26:20.460Z
Comments.Text: Hi, @nbro, I did it.
Comments.UserDisplayName: TheFnafException
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-10T21:27:44.980Z
Comments.Text: Ok, thanks for clarifying that. If you're looking for code, this site is not appropriate to ask your question (i.e. programming questions are generally off-topic here), so your question would be off-topic. You can read more about what is on-topic here: https://ai.stackexchange.com/help/on-topic, and I suggest that you read it. Are you asking for code? If yes, then probably Stack Overflow is the best place to ask your question. If you want, I can migrate your question to Stack Overflow.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-10T21:29:25.947Z
Comments.Text: Actually, No. I want to understand how to FFT-Convolve two 4D tensors with clarifying.
Comments.UserDisplayName: TheFnafException
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-10T21:33:10.700Z
Comments.Text: Thanks, @nbro again). You're really good moderator
Comments.UserDisplayName: TheFnafException
Tags: <neural-networks><convolutional-neural-networks><python><convolution>
Title: How could I convolve a 4D image and a 4D filter with stride?
UserDisplayName: TheFnafException
ThreadText: # How could I convolve a 4D image and a 4D filter with stride?
  
  (Asked by: username_0 on 2020-09-10)
  
  I want to create a CNN in Python, specifically, only with NumPy, if possible. For optimizing the time of convolution (actually correlation) in the network, I wanna try to use FFT-based convolution. The data that needs to be convoluted (correlated) is a 4D image tensor with shape `[batch_size, width, height, channels]` and 4D filter tensor `[filter_width, filter_height, in_channel, out_channel]`. I read a lot of articles about FFT-based convolution, but they aren't doing it in my way. Thus, I need your help.
  
  How could I fft-convolve a 4D image and a 4D filter with stride?
  
  **Tags:** neural-networks, convolutional-neural-networks, python, convolution
  
  > **Comments:**
  > **username_1**: Hello. It's not clear what your question is. Please, explicitly ask a specific question about your problem.  
  > **username_0**: Hi, @username_1, I did it.  
  > **username_1**: Ok, thanks for clarifying that. If you're looking for code, this site is not appropriate to ask your question (i.e. programming questions are generally off-topic here), so your question would be off-topic. You can read more about what is on-topic here: https://ai.stackexchange.com/help/on-topic, and I suggest that you read it. Are you asking for code? If yes, then probably Stack Overflow is the best place to ask your question. If you want, I can migrate your question to Stack Overflow.  
  > **username_0**: Actually, No. I want to understand how to FFT-Convolve two 4D tensors with clarifying.  
  > **username_0**: Thanks, @username_1 again). You're really good moderator  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-09-10. Score: 1
  
  I think this should work for you:
  [scipy.signal.correlate | SciPy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.correlate.html)
  
  I used it myself while I was writing a CNN in numpy.
  
  > **Comments:**
  > **username_2**: Mm, it doesn't seem optimal, but I don't know a better way that just to correlate and take elements with the corresponding step.  
  > **username_0**: Anyway, thanks for good answer. I'll use it in my code.  
  > **username_1**: Given that the OP apparently wants to implement the correlation/convolution from scratch, then maybe you should spend some words to explain how that can be conceptually done. By the way, welcome to AI SE! Have a look at our on-topic page https://ai.stackexchange.com/help/on-topic to know more about the type of question we are looking for.  
  
  ---
  
  ### Answer by username_3 on 2020-09-15. Score: 0
  
  I think what you need to use is 3D convolution operation. Your data is 3D, width, height, and num\_channels. Your data is similar to color images with RGB channels. However, since you are trying to consider the correlation amongst channels 2D convolution will not work for you. You can use 3D convolution which is available to use with deep learning tools such as Tensorflow.
  
  > **Comments:**
  > **username_0**: P.S. My data is 4D: [ batch_size, width, height, and num_channels ].  
  > **username_0**: Yes, my images are RGB  
  > **username_3**: What is the 4 dimensions in your data, i only see 3, batch_size is not a dimension of data, isnt it the batch size of the input of the neural network or is it somthing else.  
  
  ---
  
  