Skip to content

Commit d569dc3

Browse files
committed
Rename chapters
1 parent 03def3a commit d569dc3

16 files changed

+241
-287
lines changed

chapter02_mathematical-building-blocks.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{

chapter03_introduction-to-ml-frameworks.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{

chapter04_getting-started-with-neural-networks.ipynb renamed to chapter04_classification-and-regression.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{
@@ -1252,7 +1252,7 @@
12521252
"accelerator": "GPU",
12531253
"colab": {
12541254
"collapsed_sections": [],
1255-
"name": "chapter04_getting-started-with-neural-networks",
1255+
"name": "chapter04_classification-and-regression",
12561256
"private_outputs": false,
12571257
"provenance": [],
12581258
"toc_visible": true

chapter05_fundamentals-of-ml.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{

chapter07_working-with-keras.ipynb renamed to chapter07_deep-dive-keras.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{
@@ -1841,7 +1841,7 @@
18411841
"accelerator": "GPU",
18421842
"colab": {
18431843
"collapsed_sections": [],
1844-
"name": "chapter07_working-with-keras",
1844+
"name": "chapter07_deep-dive-keras",
18451845
"private_outputs": false,
18461846
"provenance": [],
18471847
"toc_visible": true

chapter08_image-classification.ipynb

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{
@@ -564,7 +564,8 @@
564564
" for i in range(9):\n",
565565
" ax = plt.subplot(3, 3, i + 1)\n",
566566
" augmented_image, _ = data_augmentation(image, None)\n",
567-
" plt.imshow(np.array(augmented_image).astype(\"uint8\"))\n",
567+
" augmented_image = keras.ops.convert_to_numpy(augmented_image)\n",
568+
" plt.imshow(augmented_image.astype(\"uint8\"))\n",
568569
" plt.axis(\"off\")"
569570
]
570571
},
@@ -663,10 +664,22 @@
663664
},
664665
"outputs": [],
665666
"source": [
666-
"conv_base = keras.applications.Xception(\n",
667-
" weights=\"imagenet\",\n",
668-
" include_top=False,\n",
669-
" input_shape=(180, 180, 3),\n",
667+
"import keras_hub\n",
668+
"\n",
669+
"conv_base = keras_hub.models.Backbone.from_preset(\"xception_41_imagenet\")"
670+
]
671+
},
672+
{
673+
"cell_type": "code",
674+
"execution_count": 0,
675+
"metadata": {
676+
"colab_type": "code"
677+
},
678+
"outputs": [],
679+
"source": [
680+
"preprocessor = keras_hub.layers.ImageConverter.from_preset(\n",
681+
" \"xception_41_imagenet\",\n",
682+
" image_size=(180, 180),\n",
670683
")"
671684
]
672685
},
@@ -687,14 +700,11 @@
687700
},
688701
"outputs": [],
689702
"source": [
690-
"import numpy as np\n",
691-
"from keras.applications.xception import preprocess_input\n",
692-
"\n",
693703
"def get_features_and_labels(dataset):\n",
694704
" all_features = []\n",
695705
" all_labels = []\n",
696706
" for images, labels in dataset:\n",
697-
" preprocessed_images = preprocess_input(images)\n",
707+
" preprocessed_images = preprocessor(images)\n",
698708
" features = conv_base.predict(preprocessed_images, verbose=0)\n",
699709
" all_features.append(features)\n",
700710
" all_labels.append(labels)\n",
@@ -809,8 +819,12 @@
809819
},
810820
"outputs": [],
811821
"source": [
812-
"conv_base = keras.applications.Xception(weights=\"imagenet\", include_top=False)\n",
813-
"conv_base.trainable = False"
822+
"import keras_hub\n",
823+
"\n",
824+
"conv_base = keras_hub.models.Backbone.from_preset(\n",
825+
" \"xception_41_imagenet\",\n",
826+
" trainable=False,\n",
827+
")"
814828
]
815829
},
816830
{
@@ -846,7 +860,7 @@
846860
"outputs": [],
847861
"source": [
848862
"inputs = keras.Input(shape=(180, 180, 3))\n",
849-
"x = preprocess_input(inputs)\n",
863+
"x = preprocessor(inputs)\n",
850864
"x = conv_base(x)\n",
851865
"x = layers.GlobalAveragePooling2D()(x)\n",
852866
"x = layers.Dense(256)(x)\n",
@@ -907,19 +921,6 @@
907921
"#### Fine-tuning a pretrained model"
908922
]
909923
},
910-
{
911-
"cell_type": "code",
912-
"execution_count": 0,
913-
"metadata": {
914-
"colab_type": "code"
915-
},
916-
"outputs": [],
917-
"source": [
918-
"conv_base.trainable = True\n",
919-
"for layer in conv_base.layers[:-4]:\n",
920-
" layer.trainable = False"
921-
]
922-
},
923924
{
924925
"cell_type": "code",
925926
"execution_count": 0,

chapter09_convnet-architecture-best-practices.ipynb renamed to chapter09_convnet-architecture-patterns.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"!pip install keras-nightly --upgrade -q"
20+
"!pip install keras-nightly keras-hub-nightly --upgrade -q"
2121
]
2222
},
2323
{
@@ -328,7 +328,7 @@
328328
"accelerator": "GPU",
329329
"colab": {
330330
"collapsed_sections": [],
331-
"name": "chapter09_convnet-architecture-best-practices",
331+
"name": "chapter09_convnet-architecture-patterns",
332332
"private_outputs": false,
333333
"provenance": [],
334334
"toc_visible": true

0 commit comments

Comments
 (0)