diff --git a/14_deep_computer_vision_with_cnns.ipynb b/14_deep_computer_vision_with_cnns.ipynb index 074c451..cd2bdaf 100644 --- a/14_deep_computer_vision_with_cnns.ipynb +++ b/14_deep_computer_vision_with_cnns.ipynb @@ -1848,6 +1848,13 @@ "# Classification and Localization" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Note**: the code below used to reuse the optimizer from the previous model. This was fine in earlier versions of TensorFlow, but in more recent versions it can cause some issues, so I added a line to create a new optimizer here." + ] + }, { "cell_type": "code", "execution_count": 55, @@ -1864,6 +1871,7 @@ "loc_output = tf.keras.layers.Dense(4)(avg)\n", "model = tf.keras.Model(inputs=base_model.input,\n", " outputs=[class_output, loc_output])\n", + "optimizer = tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9) # added this line\n", "model.compile(loss=[\"sparse_categorical_crossentropy\", \"mse\"],\n", " loss_weights=[0.8, 0.2], # depends on what you care most about\n", " optimizer=optimizer, metrics=[\"accuracy\"])" @@ -2207,7 +2215,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -2221,7 +2229,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.13" }, "nav_menu": {}, "toc": {