<p>these two steps solved my problem</p>
<ol>
<li>I found that I forget to freeze the per-trained model by setting trainable = False</li>
<li>It seams that I failed to load the weights when I get the model from keras.application even that the <a href="https://keras.io/api/applications/" rel="nofollow noreferrer">documentation</a> mentioned</li>
</ol>
<blockquote>
<p>Weights are downloaded automatically when instantiating a model. They are stored at ~/.keras/models/.</p>
</blockquote>
<p>so I get the model from <a href="https://tfhub.dev/" rel="nofollow noreferrer">tensorflow hub</a> which worked correctly</p>

CC BY-SA 4.0
2021-06-10T12:24:29.297Z
2022-07-06T13:26:38.830Z
2022-07-06T13:26:38.830Z
Hossam Alzomor
<p>I am using MobileNetV3 from TF keras for doing transfer learning; I removed the last layer, added two dense layers, and trained for 20 epochs.</p>
<ol>
<li><p>How many dense layers should I add after the MobileNet and How dense should they be?</p>
</li>
<li><p>How many epochs should I train for?</p>
</li>
<li><p>Validation loss and validation accuracy have a strange pattern, is that normal?</p>
</li>
</ol>
<p>Is there anything I am missing?</p>
<p><a href="https://i.sstatic.net/JC4L4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JC4L4.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2021-06-10T10:14:24.593Z
Hello. Maybe you should describe 1. the task you're trying to solve (and, of course, if it's a regression or classification task), 2. the dataset you're fine-tuning your model with (including its size), 3. hyper-parameters like the learning rate, the loss, optimizer and batch-size.
nbro
CC BY-SA 4.0
2021-06-10T10:22:07.263Z
1. classify person vs no person, 2.my data is 2 2d images and one depth image arranged into 3 channel image, the original data is 32X32 pixel and resized to 224X224 pixel to match the MobileNet input layer, 3. I amusing sigmoid acvtivation for last layer, adam optmizer without setting its learning rate and binary_cross_entropy for loss
Hossam Alzomor
<tensorflow><keras><transfer-learning>
Validation accuracy very low with transfer learning
Hossam Alzomor
# Validation accuracy very low with transfer learning

(Asked by: username_0 on 2021-06-08)

I am using MobileNetV3 from TF keras for doing transfer learning; I removed the last layer, added two dense layers, and trained for 20 epochs.

1. How many dense layers should I add after the MobileNet and How dense should they be?
2. How many epochs should I train for?
3. Validation loss and validation accuracy have a strange pattern, is that normal?

Is there anything I am missing?

[![enter image description here](https://i.sstatic.net/JC4L4.png)](https://i.sstatic.net/JC4L4.png)

**Tags:** tensorflow, keras, transfer-learning

> **Comments:**
> **username_1**: Hello. Maybe you should describe 1. the task you're trying to solve (and, of course, if it's a regression or classification task), 2. the dataset you're fine-tuning your model with (including its size), 3. hyper-parameters like the learning rate, the loss, optimizer and batch-size.  
> **username_0**: 1. classify person vs no person, 2.my data is 2 2d images and one depth image arranged into 3 channel image, the original data is 32X32 pixel and resized to 224X224 pixel to match the MobileNet input layer, 3. I amusing sigmoid acvtivation for last layer, adam optmizer without setting its learning rate and binary_cross_entropy for loss  

---

## 1 answers

### Answer by username_0 on 2021-06-10. Score: 1 | Accepted answer

these two steps solved my problem

1. I found that I forget to freeze the per-trained model by setting trainable = False
2. It seams that I failed to load the weights when I get the model from keras.application even that the [documentation](https://keras.io/api/applications/) mentioned

> Weights are downloaded automatically when instantiating a model. They are stored at ~/.keras/models/.

so I get the model from [tensorflow hub](https://tfhub.dev/) which worked correctly


---

