Answers.Body: <p>Each output pixel channel is a 3x3x3 filter, so 27 inputs which get multiplied by 27 weights and then added together. This is 27 FMA (fused-multiply-add) operations, or 27 multiply operations and 26 additions. I believe all modern devices implement FMA.</p>
  <p>The number of output pixel channels is 30x30x3 = 2700 (as a 3x3 kernel shaves off one pixel on each edge) and each one takes 27 operations to calculate. So that's 72900 operations in total.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-11T09:49:29.103Z
Answers.LastActivityDate: 2021-08-11T09:49:29.103Z
Answers.UserDisplayName: Criticize SE actions means ban
Body: <p>I have an input tensor of shape <span class="math-container">$\mathbf{(3, 32, 32)}$</span> consisting of 3 channels, 16 rows, and 16 columns. I want to convolve the input tensor using <span class="math-container">$\mathbf{(3 \times 3)}$</span> kernel/filter. How can I calculate the required <strong>FLOPs</strong>?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T08:53:57.723Z
Comments.Text: FLOPs required to compute it
Comments.UserDisplayName: Mhasan502
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T08:54:21.153Z
Comments.Text: First, do you know what a FLOP is?
Comments.UserDisplayName: Criticize SE actions means ban
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T09:11:57.660Z
Comments.Text: Floating point operations
Comments.UserDisplayName: Mhasan502
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T09:13:35.237Z
Comments.Text: And do you know how to calculate the output? If you know how to calculate the output, you should be able to count the FLOPs in the calculation.
Comments.UserDisplayName: Criticize SE actions means ban
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T09:14:45.820Z
Comments.Text: I don't know how to. That's why I asked the question
Comments.UserDisplayName: Mhasan502
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T09:16:44.013Z
Comments.Text: How many output channels?
Comments.UserDisplayName: Criticize SE actions means ban
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-11T09:31:48.760Z
Comments.Text: It will be the same as the input. Three
Comments.UserDisplayName: Mhasan502
Tags: <convolutional-neural-networks><filters><convolutional-layers><computational-complexity><flops>
Title: Given an input of shape $(3, 32, 32)$, which is convolved with a $(3 \times 3)$ kernel, how do I calculate the FLOPS?
UserDisplayName: Mhasan502
ThreadText: # Given an input of shape $(3, 32, 32)$, which is convolved with a $(3 \times 3)$ kernel, how do I calculate the FLOPS?
  
  (Asked by: username_0 on 2021-08-11)
  
  I have an input tensor of shape $\mathbf{(3, 32, 32)}$ consisting of 3 channels, 16 rows, and 16 columns. I want to convolve the input tensor using $\mathbf{(3 \times 3)}$ kernel/filter. How can I calculate the required **FLOPs**?
  
  **Tags:** convolutional-neural-networks, filters, convolutional-layers, computational-complexity, flops
  > **Comments:**
  > **username_0**: FLOPs required to compute it  
  > **username_1**: First, do you know what a FLOP is?  
  > **username_0**: Floating point operations  
  > **username_1**: And do you know how to calculate the output? If you know how to calculate the output, you should be able to count the FLOPs in the calculation.  
  > **username_0**: I don't know how to. That's why I asked the question  
  > **username_1**: How many output channels?  
  > **username_0**: It will be the same as the input. Three  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-11. Score: 1 | Accepted answer
  
  Each output pixel channel is a 3x3x3 filter, so 27 inputs which get multiplied by 27 weights and then added together. This is 27 FMA (fused-multiply-add) operations, or 27 multiply operations and 26 additions. I believe all modern devices implement FMA.
  
  The number of output pixel channels is 30x30x3 = 2700 (as a 3x3 kernel shaves off one pixel on each edge) and each one takes 27 operations to calculate. So that's 72900 operations in total.
  
  
  ---
  
  