Answers.Body: <p>You should do the first one: add a layer with only 4 units instead of the 1000 unit layer.</p>
  <p>You can think of the first <span class="math-container">$N-1$</span> layers as a feature extractor, converting the high-dimensional image to a (relatively) low-dimensional dense vector, and the <span class="math-container">$N$</span>th layer as a linear classifier over that dense vector. The goal during training is then to learn a feature extractor such that the output is linearly separable with respect to the classes.</p>
  <p>Because you changed the number of classes, you need to change the size of the output layer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-03T21:33:59.400Z
Answers.LastActivityDate: 2023-08-03T21:33:59.400Z
Answers.UserDisplayName: Alexander Wan
Body: <p>I am trying to implement and train neural network model VGGNet from scratch, on my own data. I am reproducing all the layers of the model. I am having a confusion about the last, fully connected softmax layer.</p>
  <p>In the research paper by Simonyan and Zisserman, the last layer of VGGNet has 1000 neurons with sotmax function. As I understand this, this layer can classify data into 1000 classes. However, my data has only 4 classes. So should I add a layer with only 4 units instead, or should I add a 1000 unit layer, and add a 4 unit layer on top of it?</p>
  
Tags: <convolutional-neural-networks><softmax><dense-layers><vgg>
Title: Number of units in Final softmax layer in VGGNet16
UserDisplayName: Dawood Ahmad
ThreadText: # Number of units in Final softmax layer in VGGNet16
  
  (Asked by: username_0 on 2023-08-03)
  
  I am trying to implement and train neural network model VGGNet from scratch, on my own data. I am reproducing all the layers of the model. I am having a confusion about the last, fully connected softmax layer.
  
  In the research paper by Simonyan and Zisserman, the last layer of VGGNet has 1000 neurons with sotmax function. As I understand this, this layer can classify data into 1000 classes. However, my data has only 4 classes. So should I add a layer with only 4 units instead, or should I add a 1000 unit layer, and add a 4 unit layer on top of it?
  
  **Tags:** convolutional-neural-networks, softmax, dense-layers, vgg
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-03. Score: 1
  
  You should do the first one: add a layer with only 4 units instead of the 1000 unit layer.
  
  You can think of the first $N-1$ layers as a feature extractor, converting the high-dimensional image to a (relatively) low-dimensional dense vector, and the $N$th layer as a linear classifier over that dense vector. The goal during training is then to learn a feature extractor such that the output is linearly separable with respect to the classes.
  
  Because you changed the number of classes, you need to change the size of the output layer.
  
  
  ---
  
  