Skip to content

Commit e87df24

Browse files
authored
Follow-up for #1854. Fix migration guide update. Bump tf-keras to 2.18.0 (#1985)
1 parent 71c53a6 commit e87df24

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

guides/ipynb/migrating_to_keras_3.ipynb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,7 @@
530530
" loss=\"categorical_crossentropy\",\n",
531531
" metrics=[\"categorical_crossentropy\", \"categorical_crossentropy\"],\n",
532532
")\n",
533-
"multi_output_model.evaluate(x_test, y_test)\n",
534-
""
533+
"multi_output_model.evaluate(x_test, y_test)\n"
535534
]
536535
},
537536
{
@@ -700,8 +699,7 @@
700699
" \"baz\": keras.Input(shape=(1,), name=\"bar\"),\n",
701700
" },\n",
702701
"}\n",
703-
"layer(inputs)\n",
704-
""
702+
"layer(inputs)\n"
705703
]
706704
},
707705
{
@@ -940,7 +938,9 @@
940938
"| `tf.scatter_nd_update` | `keras.ops.scatter_update` |\n",
941939
"| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |\n",
942940
"| `tf.signal.fft2d` | `keras.ops.fft2` |\n",
943-
"| `tf.signal.inverse_stft` | `keras.ops.istft` |"
941+
"| `tf.signal.inverse_stft` | `keras.ops.istft` |\n",
942+
"| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |\n",
943+
"| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |"
944944
]
945945
},
946946
{
@@ -973,8 +973,7 @@
973973
"class MyModel(keras.Model):\n",
974974
" def compute_loss(self, x=None, y=None, y_pred=None, sample_weight=None):\n",
975975
" loss = keras.ops.sum(keras.losses.mean_squared_error(y, y_pred, sample_weight))\n",
976-
" return loss\n",
977-
""
976+
" return loss\n"
978977
]
979978
},
980979
{
@@ -1018,8 +1017,7 @@
10181017
" pass # See guide: keras.io/guides/custom_train_step_in_tensorflow/\n",
10191018
"\n",
10201019
" def _torch_train_step(self, data):\n",
1021-
" pass # See guide: keras.io/guides/custom_train_step_in_torch/\n",
1022-
""
1020+
" pass # See guide: keras.io/guides/custom_train_step_in_torch/\n"
10231021
]
10241022
},
10251023
{
@@ -1102,8 +1100,7 @@
11021100
"source": [
11031101
"seed_generator = keras.random.SeedGenerator(1337)\n",
11041102
"print(keras.random.normal(shape=(), seed=seed_generator))\n",
1105-
"print(keras.random.normal(shape=(), seed=seed_generator))\n",
1106-
""
1103+
"print(keras.random.normal(shape=(), seed=seed_generator))\n"
11071104
]
11081105
},
11091106
{
@@ -1134,8 +1131,7 @@
11341131
" noise = keras.random.uniform(\n",
11351132
" minval=0, maxval=self.noise_rate, seed=self.seed_generator\n",
11361133
" )\n",
1137-
" return inputs + noise\n",
1138-
""
1134+
" return inputs + noise\n"
11391135
]
11401136
},
11411137
{
@@ -1178,4 +1174,4 @@
11781174
},
11791175
"nbformat": 4,
11801176
"nbformat_minor": 0
1181-
}
1177+
}

guides/md/migrating_to_keras_3.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ and click "Restart runtime" in Colab, and your code will run on the JAX or PyTor
3838
!pip install -q keras-nightly
3939
```
4040

41-
41+
4242
```python
4343
import os
4444

@@ -178,7 +178,7 @@ INFO:tensorflow:Assets written to: saved_model/assets
178178
Saved artifact at 'saved_model'. The following endpoints are available:
179179
```
180180
</div>
181-
181+
182182
<div class="k-default-codeblock">
183183
```
184184
* Endpoint 'serve'
@@ -815,6 +815,8 @@ are usually named the same in both frameworks (e.g. `reshape`, `matmul`, `cast`,
815815
| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |
816816
| `tf.signal.fft2d` | `keras.ops.fft2` |
817817
| `tf.signal.inverse_stft` | `keras.ops.istft` |
818+
| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |
819+
| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |
818820

819821
### Custom `train_step()` methods
820822

guides/migrating_to_keras_3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,8 @@ def call(self, inputs):
715715
| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |
716716
| `tf.signal.fft2d` | `keras.ops.fft2` |
717717
| `tf.signal.inverse_stft` | `keras.ops.istft` |
718-
| 'tf.image.crop_to_bounding_box' | `keras.ops.image.crop_images` |
719-
| 'tf.image.pad_to_bounding_box' | `keras.ops.image.pad_images` |
718+
| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |
719+
| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |
720720
721721
"""
722722

scripts/autogen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"keras_cv": f"{KERAS_TEAM_GH}/keras-cv/tree/v0.9.0/",
5555
"keras_nlp": f"{KERAS_TEAM_GH}/keras-nlp/tree/v0.15.1/",
5656
"keras_hub": f"{KERAS_TEAM_GH}/keras-hub/tree/v0.17.0/",
57-
"tf_keras": f"{KERAS_TEAM_GH}/tf-keras/tree/v2.17.0/",
57+
"tf_keras": f"{KERAS_TEAM_GH}/tf-keras/tree/v2.18.0/",
5858
}
5959
USE_MULTIPROCESSING = False
6060

0 commit comments

Comments
 (0)