Skip to content

Commit

Permalink
Follow-up for #1854. Fix migration guide update. Bump tf-keras to 2.1…
Browse files Browse the repository at this point in the history
…8.0 (#1985)
  • Loading branch information
fkouteib authored Nov 3, 2024
1 parent 71c53a6 commit e87df24
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
24 changes: 10 additions & 14 deletions guides/ipynb/migrating_to_keras_3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,7 @@
" loss=\"categorical_crossentropy\",\n",
" metrics=[\"categorical_crossentropy\", \"categorical_crossentropy\"],\n",
")\n",
"multi_output_model.evaluate(x_test, y_test)\n",
""
"multi_output_model.evaluate(x_test, y_test)\n"
]
},
{
Expand Down Expand Up @@ -700,8 +699,7 @@
" \"baz\": keras.Input(shape=(1,), name=\"bar\"),\n",
" },\n",
"}\n",
"layer(inputs)\n",
""
"layer(inputs)\n"
]
},
{
Expand Down Expand Up @@ -940,7 +938,9 @@
"| `tf.scatter_nd_update` | `keras.ops.scatter_update` |\n",
"| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |\n",
"| `tf.signal.fft2d` | `keras.ops.fft2` |\n",
"| `tf.signal.inverse_stft` | `keras.ops.istft` |"
"| `tf.signal.inverse_stft` | `keras.ops.istft` |\n",
"| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |\n",
"| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |"
]
},
{
Expand Down Expand Up @@ -973,8 +973,7 @@
"class MyModel(keras.Model):\n",
" def compute_loss(self, x=None, y=None, y_pred=None, sample_weight=None):\n",
" loss = keras.ops.sum(keras.losses.mean_squared_error(y, y_pred, sample_weight))\n",
" return loss\n",
""
" return loss\n"
]
},
{
Expand Down Expand Up @@ -1018,8 +1017,7 @@
" pass # See guide: keras.io/guides/custom_train_step_in_tensorflow/\n",
"\n",
" def _torch_train_step(self, data):\n",
" pass # See guide: keras.io/guides/custom_train_step_in_torch/\n",
""
" pass # See guide: keras.io/guides/custom_train_step_in_torch/\n"
]
},
{
Expand Down Expand Up @@ -1102,8 +1100,7 @@
"source": [
"seed_generator = keras.random.SeedGenerator(1337)\n",
"print(keras.random.normal(shape=(), seed=seed_generator))\n",
"print(keras.random.normal(shape=(), seed=seed_generator))\n",
""
"print(keras.random.normal(shape=(), seed=seed_generator))\n"
]
},
{
Expand Down Expand Up @@ -1134,8 +1131,7 @@
" noise = keras.random.uniform(\n",
" minval=0, maxval=self.noise_rate, seed=self.seed_generator\n",
" )\n",
" return inputs + noise\n",
""
" return inputs + noise\n"
]
},
{
Expand Down Expand Up @@ -1178,4 +1174,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
6 changes: 4 additions & 2 deletions guides/md/migrating_to_keras_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ and click "Restart runtime" in Colab, and your code will run on the JAX or PyTor
!pip install -q keras-nightly
```


```python
import os

Expand Down Expand Up @@ -178,7 +178,7 @@ INFO:tensorflow:Assets written to: saved_model/assets
Saved artifact at 'saved_model'. The following endpoints are available:
```
</div>

<div class="k-default-codeblock">
```
* Endpoint 'serve'
Expand Down Expand Up @@ -815,6 +815,8 @@ are usually named the same in both frameworks (e.g. `reshape`, `matmul`, `cast`,
| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |
| `tf.signal.fft2d` | `keras.ops.fft2` |
| `tf.signal.inverse_stft` | `keras.ops.istft` |
| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |
| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |

### Custom `train_step()` methods

Expand Down
4 changes: 2 additions & 2 deletions guides/migrating_to_keras_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ def call(self, inputs):
| `tf.tensor_scatter_nd_update` | `keras.ops.slice_update` |
| `tf.signal.fft2d` | `keras.ops.fft2` |
| `tf.signal.inverse_stft` | `keras.ops.istft` |
| 'tf.image.crop_to_bounding_box' | `keras.ops.image.crop_images` |
| 'tf.image.pad_to_bounding_box' | `keras.ops.image.pad_images` |
| `tf.image.crop_to_bounding_box` | `keras.ops.image.crop_images` |
| `tf.image.pad_to_bounding_box` | `keras.ops.image.pad_images` |
"""

Expand Down
2 changes: 1 addition & 1 deletion scripts/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"keras_cv": f"{KERAS_TEAM_GH}/keras-cv/tree/v0.9.0/",
"keras_nlp": f"{KERAS_TEAM_GH}/keras-nlp/tree/v0.15.1/",
"keras_hub": f"{KERAS_TEAM_GH}/keras-hub/tree/v0.17.0/",
"tf_keras": f"{KERAS_TEAM_GH}/tf-keras/tree/v2.17.0/",
"tf_keras": f"{KERAS_TEAM_GH}/tf-keras/tree/v2.18.0/",
}
USE_MULTIPROCESSING = False

Expand Down

0 comments on commit e87df24

Please sign in to comment.