Answers.Body: <p>Yes, this is quite the expected behavior. The main difference between expected and current behavior lies in the amount of data you are using for training VS the amount of data that the pre-trained model was trained with.</p>
  <p>Take into account that pre-trained models have been trained over popular datasets, the most common ones are: <a href="https://cocodataset.org/#home" rel="nofollow noreferrer">COCO</a>, <a href="https://image-net.org/download.php" rel="nofollow noreferrer">ImageNet</a> and <a href="https://storage.googleapis.com/openimages/web/index.html" rel="nofollow noreferrer">Open Images</a>. And the amount of data differs:</p>
  <ul>
  <li>COCO: 330K images</li>
  <li>ImageNet: 1.5M images</li>
  <li>OpenImages: 9M images</li>
  <li>Your dataset: 20K images</li>
  </ul>
  <p>You could say, well, but I started from a pre-trained model, so the network should already know how to detect a person. Well that is true, but you are training it again, you are not using transfer learning (freezing backbone layers, or adding extra heads / extra channels to detect other features or other classes). So what is happening is that your model, even when it started from good pre-trained weights, is fitting to your 20K images data.</p>
  <p>As I see it, you have two options: either increase your dataset size or use <a href="https://towardsdatascience.com/the-ultimate-guide-to-transfer-learning-ebf83b655391" rel="nofollow noreferrer">transfer leanring</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-15T05:17:13.610Z
Answers.Text: Thank you for great answer. Do you know how to freeze the layers of a model using TFOD? That is, how do I know which layers to freeze based on the name of them?
Answers.UserDisplayName: Araw
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-15T12:21:50.590Z
Answers.Text: I am using pytorch for two years now, but last time I checked you needed to iterate the model layers and set the target layers to `trainable=false`
Answers.UserDisplayName: JVGD
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-14T11:18:12.043Z
Answers.LastActivityDate: 2021-07-14T11:18:12.043Z
Answers.UserDisplayName: JVGD
Body: <p>I have downloaded a pre-trained EfficientDet D2 model (Tensorflow 2.0) and trained it on some data (about 20000 images with 20 classes). I set the number of steps to 25000 and batch size to 3 (computer resources are not the best).</p>
  <p>However, if I try to make predictions, the pre-trained model makes better predictions than the model I have trained on the additional data. Is this expected behaviour?</p>
  <p>For example, an image of a person may be 78% accurate on the pre-trained model and only 54% accurate on the same image when trained.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-14T11:31:07.143Z
Comments.Text: Hello. Welcome to AI SE! I changed the title of your post to put there what I think is your question. Please, make sure the current version of your post is still consistent with your original post.
Comments.UserDisplayName: nbro
Tags: <tensorflow><object-detection><transfer-learning><pretrained-models><fine-tuning>
Title: Is it possible that the fine-tuned pre-trained model performs worse than the original pre-trained model?
UserDisplayName: Araw
ThreadText: # Is it possible that the fine-tuned pre-trained model performs worse than the original pre-trained model?
  
  (Asked by: username_0 on 2021-07-13)
  
  I have downloaded a pre-trained EfficientDet D2 model (Tensorflow 2.0) and trained it on some data (about 20000 images with 20 classes). I set the number of steps to 25000 and batch size to 3 (computer resources are not the best).
  
  However, if I try to make predictions, the pre-trained model makes better predictions than the model I have trained on the additional data. Is this expected behaviour?
  
  For example, an image of a person may be 78% accurate on the pre-trained model and only 54% accurate on the same image when trained.
  
  **Tags:** tensorflow, object-detection, transfer-learning, pretrained-models, fine-tuning
  
  > **Comments:**
  > **username_1**: Hello. Welcome to AI SE! I changed the title of your post to put there what I think is your question. Please, make sure the current version of your post is still consistent with your original post.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-07-14. Score: 4 | Accepted answer
  
  Yes, this is quite the expected behavior. The main difference between expected and current behavior lies in the amount of data you are using for training VS the amount of data that the pre-trained model was trained with.
  
  Take into account that pre-trained models have been trained over popular datasets, the most common ones are: [COCO](https://cocodataset.org/#home), [ImageNet](https://image-net.org/download.php) and [Open Images](https://storage.googleapis.com/openimages/web/index.html). And the amount of data differs:
  
  * COCO: 330K images
  * ImageNet: 1.5M images
  * OpenImages: 9M images
  * Your dataset: 20K images
  
  You could say, well, but I started from a pre-trained model, so the network should already know how to detect a person. Well that is true, but you are training it again, you are not using transfer learning (freezing backbone layers, or adding extra heads / extra channels to detect other features or other classes). So what is happening is that your model, even when it started from good pre-trained weights, is fitting to your 20K images data.
  
  As I see it, you have two options: either increase your dataset size or use [transfer leanring](https://towardsdatascience.com/the-ultimate-guide-to-transfer-learning-ebf83b655391).
  
  > **Comments:**
  > **username_0**: Thank you for great answer. Do you know how to freeze the layers of a model using TFOD? That is, how do I know which layers to freeze based on the name of them?  
  > **username_2**: I am using pytorch for two years now, but last time I checked you needed to iterate the model layers and set the target layers to `trainable=false`  
  
  ---
  
  