Answers.Body: <p>Even if you want to re-train your model for just one new class you will have to prepare your training data such that it includes all or most of the classes which you want to predict. Most of the times last two layers of a network have the data of number of labels which are to be predicted and that should always be sum of the number of classes you already trained on and the number of classes you want to add for training.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-03T14:37:25.963Z
Answers.LastActivityDate: 2019-09-03T14:37:25.963Z
Answers.UserDisplayName: Mousam Singh
Body: <p>I am basically interested in vehicle on the road.  </p>
  
  <p><a href="https://github.com/ayooshkathuria/pytorch-yolo-v3" rel="nofollow noreferrer">YoloV3 pytorch</a> is giving a decent result.</p>
  
  <p>So my interested Vehicles <code>Car</code> <code>Motorbike</code> <code>Bicycle</code> <code>Truck</code> and <code>bus</code>, I have a small vehicles being detected as <code>truck</code>.</p>
  
  <p>Since the small vehicle is nicely being detected as truck. I have annotated this small vehicle as a different class.</p>
  
  <p>Though, I could add an extra class say 81th class, since the current YoloV3 being used is trained on 80 classes.</p>
  
  <p>81th class would contain the weight of the truck, I would freeze the weights such that the rest of the 80 classes remain unaltered and only the 81th class of this new data gets trained.</p>
  
  <p>The problem is the final layer gets tuned according to the prediction of all the classes it learns.</p>
  
  <p>I was not able to find any post that could actually mention this way of preserving the predictions of the other classes and introducing a new class using transfer learning.</p>
  
  <p>The closest, I was able to get is this post of 
  <a href="https://github.com/pierluigiferrari/ssd_keras/blob/master/weight_sampling_tutorial.ipynb" rel="nofollow noreferrer">Weight Sampling Tutorial</a> SSD using keras</p>
  
  <p>Its mentioned in</p>
  
  <p><strong>Option 1: Just ignore the fact that we need only 8 classes</strong></p>
  
  <p><code>This would work, and it wouldn't even be a terrible option. Since only 8 out of the 80 classes would get trained, the model might get gradually worse at predicting the other 72 clases</code> in the second paragraph.</p>
  
  <p>Is it possible to preserve the predictions, of the previous pre trained model while introducing the new class and use transfer learning to train only for that class?</p>
  
  <p>I Feel that this is not possible, would like to know your opinion. Hope someone can prove me wrong. </p>
  
Tags: <convolutional-neural-networks><transfer-learning><incremental-learning>
Title: Transfer learning to train only for a new class while not affecting the predictions of the other class
UserDisplayName: Santhosh Dhaipule Chandrakanth
ThreadText: # Transfer learning to train only for a new class while not affecting the predictions of the other class
  
  (Asked by: username_0 on 2019-08-26)
  
  I am basically interested in vehicle on the road.
  
  [YoloV3 pytorch](https://github.com/ayooshkathuria/pytorch-yolo-v3) is giving a decent result.
  
  So my interested Vehicles `Car` `Motorbike` `Bicycle` `Truck` and `bus`, I have a small vehicles being detected as `truck`.
  
  Since the small vehicle is nicely being detected as truck. I have annotated this small vehicle as a different class.
  
  Though, I could add an extra class say 81th class, since the current YoloV3 being used is trained on 80 classes.
  
  81th class would contain the weight of the truck, I would freeze the weights such that the rest of the 80 classes remain unaltered and only the 81th class of this new data gets trained.
  
  The problem is the final layer gets tuned according to the prediction of all the classes it learns.
  
  I was not able to find any post that could actually mention this way of preserving the predictions of the other classes and introducing a new class using transfer learning.
  
  The closest, I was able to get is this post of
  [Weight Sampling Tutorial](https://github.com/pierluigiferrari/ssd_keras/blob/master/weight_sampling_tutorial.ipynb) SSD using keras
  
  Its mentioned in
  
  **Option 1: Just ignore the fact that we need only 8 classes**
  
  `This would work, and it wouldn't even be a terrible option. Since only 8 out of the 80 classes would get trained, the model might get gradually worse at predicting the other 72 clases` in the second paragraph.
  
  Is it possible to preserve the predictions, of the previous pre trained model while introducing the new class and use transfer learning to train only for that class?
  
  I Feel that this is not possible, would like to know your opinion. Hope someone can prove me wrong.
  
  **Tags:** convolutional-neural-networks, transfer-learning, incremental-learning
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-03. Score: 1
  
  Even if you want to re-train your model for just one new class you will have to prepare your training data such that it includes all or most of the classes which you want to predict. Most of the times last two layers of a network have the data of number of labels which are to be predicted and that should always be sum of the number of classes you already trained on and the number of classes you want to add for training.
  
  
  ---
  
  