mrdbourke / tensorflow-deep-learning

All course materials for the Zero to Mastery Deep Learning with TensorFlow course.
https://dbourke.link/ZTMTFcourse
MIT License
5.05k stars 2.5k forks source link

initial_epoch value for fine-tuning #552

Open Peco602 opened 1 year ago

Peco602 commented 1 year ago

Looking at the following code it seems the model is being trained for 11 epochs and not 10:

# Fine tune for another 5 epochs
fine_tune_epochs = initial_epochs + 5

# Refit the model (same as model_2 except with more trainable layers)
history_fine_10_percent_data_aug = model_2.fit(train_data_10_percent,
                                               epochs=fine_tune_epochs,
                                               validation_data=test_data,
                                               initial_epoch=history_10_percent_data_aug.epoch[-1], # start from previous last epoch
                                               validation_steps=int(0.25 * len(test_data)),
                                               callbacks=[create_tensorboard_callback("transfer_learning", "10_percent_fine_tune_last_10")])

Are you sure initial_epoch should not be set to history_10_percent_data_aug.epoch[-1]+1 so the fine-tuning starts from epochs 6?

brimerr commented 1 month ago

I think it actually suppose to stop at 9 because the first epoch is actually zero. 0 to 9 is 10 epochs