Skip to content

Commit 7ba522a

Browse files
committed
Small fixes in ch7
1 parent 8428a87 commit 7ba522a

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

chapter07_working-with-keras.ipynb

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@
567567
},
568568
"outputs": [],
569569
"source": [
570-
"keras.utils.plot_model(model, \"updated_ticket_classifier.png\", show_shapes=True)"
570+
"keras.utils.plot_model(new_model, \"updated_ticket_classifier.png\", show_shapes=True)"
571571
]
572572
},
573573
{
@@ -846,8 +846,7 @@
846846
"\n",
847847
" def __init__(self, name=\"rmse\", **kwargs):\n",
848848
" super().__init__(name=name, **kwargs)\n",
849-
" self.mse_sum = self.add_weight(\n",
850-
" name=\"mse_sum\", initializer=\"zeros\")\n",
849+
" self.mse_sum = self.add_weight(name=\"mse_sum\", initializer=\"zeros\")\n",
851850
" self.total_samples = self.add_weight(\n",
852851
" name=\"total_samples\", initializer=\"zeros\", dtype=\"int32\")\n",
853852
"\n",
@@ -925,7 +924,7 @@
925924
" patience=1,\n",
926925
" ),\n",
927926
" keras.callbacks.ModelCheckpoint(\n",
928-
" filepath=\"my_checkpoint_path\",\n",
927+
" filepath=\"checkpoint_path.keras\",\n",
929928
" monitor=\"val_loss\",\n",
930929
" save_best_only=True,\n",
931930
" )\n",
@@ -948,7 +947,7 @@
948947
},
949948
"outputs": [],
950949
"source": [
951-
"model = keras.models.load_model(\"my_checkpoint_path\")"
950+
"model = keras.models.load_model(\"checkpoint_path.keras\")"
952951
]
953952
},
954953
{
@@ -1024,6 +1023,40 @@
10241023
"### Monitoring and visualization with TensorBoard"
10251024
]
10261025
},
1026+
{
1027+
"cell_type": "code",
1028+
"execution_count": 0,
1029+
"metadata": {
1030+
"colab_type": "code"
1031+
},
1032+
"outputs": [],
1033+
"source": [
1034+
"model = get_mnist_model()\n",
1035+
"model.compile(optimizer=\"rmsprop\",\n",
1036+
" loss=\"sparse_categorical_crossentropy\",\n",
1037+
" metrics=[\"accuracy\"])\n",
1038+
"\n",
1039+
"tensorboard = keras.callbacks.TensorBoard(\n",
1040+
" log_dir=\"/full_path_to_your_log_dir\",\n",
1041+
")\n",
1042+
"model.fit(train_images, train_labels,\n",
1043+
" epochs=10,\n",
1044+
" validation_data=(val_images, val_labels),\n",
1045+
" callbacks=[tensorboard])"
1046+
]
1047+
},
1048+
{
1049+
"cell_type": "code",
1050+
"execution_count": 0,
1051+
"metadata": {
1052+
"colab_type": "code"
1053+
},
1054+
"outputs": [],
1055+
"source": [
1056+
"%load_ext tensorboard\n",
1057+
"%tensorboard --logdir /full_path_to_your_log_dir"
1058+
]
1059+
},
10271060
{
10281061
"cell_type": "markdown",
10291062
"metadata": {

0 commit comments

Comments
 (0)