Answers.Body: <p>Let's say you are training a CNN to classify whether an image has a dog or a cat. Your dataset has only one (grayscale) photo of each, but they have a high resolution of 6000 x 4000 pixels. Wouldn't you expect the network to overfit, even though you have 2 x 6000 x 4000 = 48 million input pixels?</p>
  <p>It will overfit, because after all it has only seen one dog and one cat. It might learn to make the distinction based on the background, or other irrelevant information. The network needs sufficiently many examples of each class to learn what is relevant and what isn't. Increasing the number of pixels / image doesn't change this.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-01T12:55:28.893Z
Answers.Text: Thank you. Are there any rules apply to CNN to compare the number of inputs and the number of parameters? And also for the sample size, for sample size, I am referring to the data points here. For traditional models, we use rule of thumb.
Answers.UserDisplayName: rodericktung
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-01T09:39:14.573Z
Answers.LastActivityDate: 2022-07-01T09:39:14.573Z
Answers.UserDisplayName: NikoNyrh
Body: <p>I search this kind of question for a while and I find many discussions involve on counting the number of parameters of a Convolutional Neural Network, but not on the inputs. Using the Fashion MNIST dataset as an example, each black and white image has <span class="math-container">$28 \times 28 \times 1$</span> pixels and there are 60,000 images in the training dataset. Does that mean we have total number of <span class="math-container">$28 \times 28 \times 60,000=47,040,000$</span> inputs for the input layer of CNN?</p>
  <p>My partner critics my baseline/simplest CNN model (for demo purpose) with just one convolutional layer with 10 filters/kernels (the kernel size is <span class="math-container">$3 \times 3$</span>
  ), padding has been used and strides = 1. The Keras model information is listed below. He says the training set only have a sample size of 60,000, but you have 78,510 parameters. He concerns over-fitting issues because I have more parameters than the inputs.</p>
  <p><a href="https://i.sstatic.net/Em7tD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Em7tD.png" alt="enter image description here" /></a></p>
  <p>I really don't know how to explain the concepts to him clearly that the inputs of CNN are pixels. Could anyone help? A more detailed explanation will be very helpful and I am also happy to learn!</p>
  
Tags: <convolutional-neural-networks><classification><image-processing><weights>
Title: How to calculate the total number of inputs in CNN?
UserDisplayName: rodericktung
ThreadText: # How to calculate the total number of inputs in CNN?
  
  (Asked by: username_0 on 2022-07-01)
  
  I search this kind of question for a while and I find many discussions involve on counting the number of parameters of a Convolutional Neural Network, but not on the inputs. Using the Fashion MNIST dataset as an example, each black and white image has $28 \times 28 \times 1$ pixels and there are 60,000 images in the training dataset. Does that mean we have total number of $28 \times 28 \times 60,000=47,040,000$ inputs for the input layer of CNN?
  
  My partner critics my baseline/simplest CNN model (for demo purpose) with just one convolutional layer with 10 filters/kernels (the kernel size is $3 \times 3$
  ), padding has been used and strides = 1. The Keras model information is listed below. He says the training set only have a sample size of 60,000, but you have 78,510 parameters. He concerns over-fitting issues because I have more parameters than the inputs.
  
  [![enter image description here](https://i.sstatic.net/Em7tD.png)](https://i.sstatic.net/Em7tD.png)
  
  I really don't know how to explain the concepts to him clearly that the inputs of CNN are pixels. Could anyone help? A more detailed explanation will be very helpful and I am also happy to learn!
  
  **Tags:** convolutional-neural-networks, classification, image-processing, weights
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-01. Score: 1
  
  Let's say you are training a CNN to classify whether an image has a dog or a cat. Your dataset has only one (grayscale) photo of each, but they have a high resolution of 6000 x 4000 pixels. Wouldn't you expect the network to overfit, even though you have 2 x 6000 x 4000 = 48 million input pixels?
  
  It will overfit, because after all it has only seen one dog and one cat. It might learn to make the distinction based on the background, or other irrelevant information. The network needs sufficiently many examples of each class to learn what is relevant and what isn't. Increasing the number of pixels / image doesn't change this.
  
  > **Comments:**
  > **username_0**: Thank you. Are there any rules apply to CNN to compare the number of inputs and the number of parameters? And also for the sample size, for sample size, I am referring to the data points here. For traditional models, we use rule of thumb.  
  
  ---
  
  