Answers.Body: <p>I don't have an exact answer to your question because I think your question is a bit ambiguous. It's like asking &quot;How many defenders do you need to replace your forwards?&quot;: they do slightly different things, but a defender occasionally may be able to play as a forward. Anyway, given that I think this question arises because you don't understand how we can view a CNN as an FFNN or vice-versa, I will try to give you an idea of the relationship between the two and the number of parameters in a CNN and an FFNN.</p>
  <p>Before proceeding, read my answer <a href="https://ai.stackexchange.com/a/25850/2444">here</a> (and maybe the other answer there too), which will give you an idea of what we could consider a neuron in a CNN, and how we can compare CNNs to FFNNs. After that, you could read <a href="https://ai.stackexchange.com/a/21401/2444">this answer</a> to understand why we need CNNs and why we use them in the context of computer vision. From now on, I will assume that you have an idea of how CNNs work, what filters are, etc., but I will remind you of a few details.</p>
  <p>CNNs are specifically designed to deal with images, so CNNs have a more appropriate <a href="https://ai.stackexchange.com/a/31600/2444"><strong>inductive bias</strong></a> than FFNNs for image processing.</p>
  <p>A specific filter/kernel in a CNN can be thought of as extracting the same type of feature from different parts of the image. At a high level, this makes sense, because the same object/feature (e.g. an eye) can appear in different parts of an image. If you are familiar with image processing techniques, this interpretation of the role of kernels in CNNs shouldn't be too strange.</p>
  <p>One of the main properties of CNNs, as explained in the linked answers, is that of <strong>weight sharing</strong>. This means that you apply the same filter (weights) to different parts of the image (this is basically what the <a href="https://ai.stackexchange.com/q/21999/2444">convolution operation</a> is doing). So, you try to extract the same &quot;features&quot; with the same kernel from different parts of the image.</p>
  <p>Now, imagine if you didn't do that, and you had to learn different filters for different parts of the image: we would need weights for all these different parts, so we would need a lot more weights.</p>
  <p>In the case of an FFNN, we can view the operation of a fully connected layer as a convolution with a kernel as big as the input image. More precisely, if you have <span class="math-container">$n$</span> neurons in layer <span class="math-container">$l$</span> and <span class="math-container">$m$</span> neurons in layer <span class="math-container">$l-1$</span>, then you can view this FC layer as performing <span class="math-container">$n$</span> convolutions, one for each neuron in <span class="math-container">$l$</span>, with a kernel with <span class="math-container">$m$</span> weights.</p>
  <p>At this point, you should start to see the relationship between fully connected layers and convolutional layers.</p>
  <p>So, what's the answer to your question? I don't know. It depends on what you mean by &quot;equivalent&quot;. If by &quot;equivalent&quot; you mean they are the same <a href="https://ai.stackexchange.com/a/23005/2444">hypothesis class</a>, then that's a question to which I don't have an answer. However, both FC and CNNs are <a href="https://ai.stackexchange.com/a/13319/2444">universal function approximators</a>, so, in a way, they are equivalent, exactly how (which is your question), I don't know and this is probably an open research question. One thing we can say is that CNNs have a more appropriate inductive bias than FFNNs to deal with images.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-04T15:01:36.283Z
Answers.Text: I may delete this answer later as the question, in my view, is not clear enough. This would have been comment, if comments could be this long.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-04T14:49:46.933Z
Answers.LastActivityDate: 2022-01-04T15:05:33.670Z
Answers.LastEditDate: 2022-01-04T15:05:33.670Z
Answers.UserDisplayName: nbro
Body: <p>I started to learn machine learning early, and I studied the convolutional neural network and its ability to understand images and how it helps to reduce the number of parameters that need to be tuned.</p>
  <p>So, if I used CNN rather than a feed-forward network for the image classification problem, how many neurons and layers would I save or discard?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-04T10:32:19.610Z
Comments.Text: What do you understand about CNNs? Do you know how they work? For example, do you understand how the convolution works?
Comments.UserDisplayName: nbro
Tags: <convolutional-neural-networks><comparison><weights><feedforward-neural-networks>
Title: How many layers and neurons in a FFNN do I need to make it equivalent to a CNN?
UserDisplayName: Mahmoud Kanbar
ThreadText: # How many layers and neurons in a FFNN do I need to make it equivalent to a CNN?
  
  (Asked by: username_0 on 2022-01-03)
  
  I started to learn machine learning early, and I studied the convolutional neural network and its ability to understand images and how it helps to reduce the number of parameters that need to be tuned.
  
  So, if I used CNN rather than a feed-forward network for the image classification problem, how many neurons and layers would I save or discard?
  
  **Tags:** convolutional-neural-networks, comparison, weights, feedforward-neural-networks
  > **Comments:**
  > **username_1**: What do you understand about CNNs? Do you know how they work? For example, do you understand how the convolution works?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-04. Score: 0 | Accepted answer
  
  I don't have an exact answer to your question because I think your question is a bit ambiguous. It's like asking "How many defenders do you need to replace your forwards?": they do slightly different things, but a defender occasionally may be able to play as a forward. Anyway, given that I think this question arises because you don't understand how we can view a CNN as an FFNN or vice-versa, I will try to give you an idea of the relationship between the two and the number of parameters in a CNN and an FFNN.
  
  Before proceeding, read my answer [here](https://ai.stackexchange.com/a/25850/2444) (and maybe the other answer there too), which will give you an idea of what we could consider a neuron in a CNN, and how we can compare CNNs to FFNNs. After that, you could read [this answer](https://ai.stackexchange.com/a/21401/2444) to understand why we need CNNs and why we use them in the context of computer vision. From now on, I will assume that you have an idea of how CNNs work, what filters are, etc., but I will remind you of a few details.
  
  CNNs are specifically designed to deal with images, so CNNs have a more appropriate [**inductive bias**](https://ai.stackexchange.com/a/31600/2444) than FFNNs for image processing.
  
  A specific filter/kernel in a CNN can be thought of as extracting the same type of feature from different parts of the image. At a high level, this makes sense, because the same object/feature (e.g. an eye) can appear in different parts of an image. If you are familiar with image processing techniques, this interpretation of the role of kernels in CNNs shouldn't be too strange.
  
  One of the main properties of CNNs, as explained in the linked answers, is that of **weight sharing**. This means that you apply the same filter (weights) to different parts of the image (this is basically what the [convolution operation](https://ai.stackexchange.com/q/21999/2444) is doing). So, you try to extract the same "features" with the same kernel from different parts of the image.
  
  Now, imagine if you didn't do that, and you had to learn different filters for different parts of the image: we would need weights for all these different parts, so we would need a lot more weights.
  
  In the case of an FFNN, we can view the operation of a fully connected layer as a convolution with a kernel as big as the input image. More precisely, if you have $n$ neurons in layer $l$ and $m$ neurons in layer $l-1$, then you can view this FC layer as performing $n$ convolutions, one for each neuron in $l$, with a kernel with $m$ weights.
  
  At this point, you should start to see the relationship between fully connected layers and convolutional layers.
  
  So, what's the answer to your question? I don't know. It depends on what you mean by "equivalent". If by "equivalent" you mean they are the same [hypothesis class](https://ai.stackexchange.com/a/23005/2444), then that's a question to which I don't have an answer. However, both FC and CNNs are [universal function approximators](https://ai.stackexchange.com/a/13319/2444), so, in a way, they are equivalent, exactly how (which is your question), I don't know and this is probably an open research question. One thing we can say is that CNNs have a more appropriate inductive bias than FFNNs to deal with images.
  
  > **Comments:**
  > **username_1**: I may delete this answer later as the question, in my view, is not clear enough. This would have been comment, if comments could be this long.  
  
  ---
  
  