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

  • $\begingroup$ 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. $\endgroup$
    – nbro
    Jun 10, 2021 at 10:14
  • $\begingroup$ 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 $\endgroup$ Jun 10, 2021 at 10:22

1 Answer 1


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 mentioned

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

so I get the model from tensorflow hub which worked correctly


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .