From 8156353da0046a2f2db92dec94327f0144ce45f5 Mon Sep 17 00:00:00 2001 From: sharkfisher Date: Sun, 17 Dec 2023 16:37:45 -0800 Subject: [PATCH 1/2] Update transfer_learning.ipynb - fix initial_epoch for fine tuning initial_epoch for the fine tuning phase should be 1 more than history.epoch[-1], so that the history_fine.epoch would be [10, 11, ...19], a total of 10 fine tune epochs. Without the '+1', history.epoch is [0, 1, ...9], and history_fine.epoch is [9, 10, ... 19], the epoch index overlaps at 9, fine tune actually trained for 11 epochs, not 10, and the model is actually trained for 21 epochs in total (confirmed in the x axis of the combined training history curve - 21 data points) --- site/en/tutorials/images/transfer_learning.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/en/tutorials/images/transfer_learning.ipynb b/site/en/tutorials/images/transfer_learning.ipynb index 6406ccdce74..3342c6eb838 100644 --- a/site/en/tutorials/images/transfer_learning.ipynb +++ b/site/en/tutorials/images/transfer_learning.ipynb @@ -930,7 +930,7 @@ "\n", "history_fine = model.fit(train_dataset,\n", " epochs=total_epochs,\n", - " initial_epoch=history.epoch[-1],\n", + " initial_epoch=history.epoch[-1]+1,\n", " validation_data=validation_dataset)" ] }, From e96ecf10bf0b39abe50722b1cc28e747091001bc Mon Sep 17 00:00:00 2001 From: M Liang Date: Mon, 18 Dec 2023 12:15:21 -0800 Subject: [PATCH 2/2] Alternative fix for initial_epoch (better conceptualization). Formatting check. --- site/en/tutorials/images/transfer_learning.ipynb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/site/en/tutorials/images/transfer_learning.ipynb b/site/en/tutorials/images/transfer_learning.ipynb index 3342c6eb838..dd9b97cabe2 100644 --- a/site/en/tutorials/images/transfer_learning.ipynb +++ b/site/en/tutorials/images/transfer_learning.ipynb @@ -930,7 +930,7 @@ "\n", "history_fine = model.fit(train_dataset,\n", " epochs=total_epochs,\n", - " initial_epoch=history.epoch[-1]+1,\n", + " initial_epoch=len(history.epoch),\n", " validation_data=validation_dataset)" ] }, @@ -1081,22 +1081,12 @@ "\n", "To learn more, visit the [Transfer learning guide](https://www.tensorflow.org/guide/keras/transfer_learning).\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "uKIByL01da8c" - }, - "outputs": [], - "source": [] } ], "metadata": { "accelerator": "GPU", "colab": { "name": "transfer_learning.ipynb", - "private_outputs": true, "toc_visible": true }, "kernelspec": {