|
70 | 70 | "This guide demonstrates how to migrate from TensorFlow 1's `tf.estimator.Estimator` APIs to TensorFlow 2's `tf.keras` APIs. First, you will set up and run a basic model for training and evaluation with `tf.estimator.Estimator`. Then, you will perform the equivalent steps in TensorFlow 2 with the `tf.keras` APIs. You will also learn how to customize the training step by subclassing `tf.keras.Model` and using `tf.GradientTape`.\n", |
71 | 71 | "\n", |
72 | 72 | "- In TensorFlow 1, the high-level `tf.estimator.Estimator` APIs let you train and evaluate a model, as well as perform inference and save your model (for serving).\n", |
73 | | - "- In TensorFlow 2, use the Keras APIs to perform the aforementioned tasks, such as [model building](../../guide/keras/custom_layers_and_models.ipynb), gradient application, [training](../../guide/keras/customizing_what_happens_in_fit.ipynb), evaluation, and prediction.\n", |
| 73 | + "- In TensorFlow 2, use the Keras APIs to perform the aforementioned tasks, such as [model building](https://www.tensorflow.org/guide/keras/custom_layers_and_models), gradient application, [training](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit), evaluation, and prediction.\n", |
74 | 74 | "\n", |
75 | 75 | "(For migrating model/checkpoint saving workflows to TensorFlow 2, check out the [SavedModel](saved_model.ipynb) and [Checkpoint](checkpoint_saved.ipynb) migration guides.)" |
76 | 76 | ] |
|
197 | 197 | "source": [ |
198 | 198 | "## TensorFlow 2: Train and evaluate with the built-in Keras methods\n", |
199 | 199 | "\n", |
200 | | - "This example demonstrates how to perform training and evaluation with Keras `Model.fit` and `Model.evaluate` in TensorFlow 2. (You can learn more in the [Training and evaluation with the built-in methods](../../guide/keras/train_and_evaluate.ipynb) guide.)\n", |
| 200 | + "This example demonstrates how to perform training and evaluation with Keras `Model.fit` and `Model.evaluate` in TensorFlow 2. (You can learn more in the [Training and evaluation with the built-in methods](https://www.tensorflow.org/guide/keras/train_and_evaluate) guide.)\n", |
201 | 201 | "\n", |
202 | 202 | "- Start by preparing the dataset pipeline with the `tf.data.Dataset` APIs.\n", |
203 | | - "- Define a simple Keras [Sequential](../../guide/keras/sequential_model.ipynb) model with one linear (`tf.keras.layers.Dense`) layer.\n", |
| 203 | + "- Define a simple Keras [Sequential](https://www.tensorflow.org/guide/keras/sequential_model) model with one linear (`tf.keras.layers.Dense`) layer.\n", |
204 | 204 | "- Instantiate an Adagrad optimizer (`tf.keras.optimizers.Adagrad`).\n", |
205 | 205 | "- Configure the model for training by passing the `optimizer` variable and the mean-squared error (`\"mse\"`) loss to `Model.compile`." |
206 | 206 | ] |
|
278 | 278 | "id": "gHx_RUL8xcJ3" |
279 | 279 | }, |
280 | 280 | "source": [ |
281 | | - "In TensorFlow 2, you can also write your own custom training step function with `tf.GradientTape` to perform forward and backward passes, while still taking advantage of the built-in training support, such as `tf.keras.callbacks.Callback` and `tf.distribute.Strategy`. (Learn more in [Customizing what happens in Model.fit](../../guide/keras/customizing_what_happens_in_fit.ipynb) and [Writing custom training loops from scratch](../../guide/keras/writing_a_training_loop_from_scratch.ipynb).)\n", |
| 281 | + "In TensorFlow 2, you can also write your own custom training step function with `tf.GradientTape` to perform forward and backward passes, while still taking advantage of the built-in training support, such as `tf.keras.callbacks.Callback` and `tf.distribute.Strategy`. (Learn more in [Customizing what happens in Model.fit](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit) and [Writing custom training loops from scratch](https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch).)\n", |
282 | 282 | "\n", |
283 | | - "In this example, start by creating a custom `tf.keras.Model` by subclassing `tf.keras.Sequential` that overrides `Model.train_step`. (Learn more about [subclassing tf.keras.Model](../../keras/custom_layers_and_models.ipynb)). Inside that class, define a custom `train_step` function that for each batch of data performs a forward pass and backward pass during one training step.\n" |
| 283 | + "In this example, start by creating a custom `tf.keras.Model` by subclassing `tf.keras.Sequential` that overrides `Model.train_step`. (Learn more about [subclassing tf.keras.Model](https://www.tensorflow.org/guide/keras/custom_layers_and_models)). Inside that class, define a custom `train_step` function that for each batch of data performs a forward pass and backward pass during one training step.\n" |
284 | 284 | ] |
285 | 285 | }, |
286 | 286 | { |
|
394 | 394 | "\n", |
395 | 395 | "Additional Keras resources you may find useful:\n", |
396 | 396 | "\n", |
397 | | - "- Guide: [Training and evaluation with the built-in methods](../../guide/keras/train_and_evaluate.ipynb)\n", |
398 | | - "- Guide: [Customize what happens in Model.fit](../../guide/keras/customizing_what_happens_in_fit.ipynb)\n", |
399 | | - "- Guide: [Writing a training loop from scratch](../../guide/keras/writing_a_training_loop_from_scratch.ipynb)\n", |
400 | | - "- Guide: [Making new Keras layers and models via subclassing](../../guide/keras/custom_layers_and_models.ipynb)\n", |
| 397 | + "- Guide: [Training and evaluation with the built-in methods](https://www.tensorflow.org/guide/keras/train_and_evaluate)\n", |
| 398 | + "- Guide: [Customize what happens in Model.fit](https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit)\n", |
| 399 | + "- Guide: [Writing a training loop from scratch](https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch)\n", |
| 400 | + "- Guide: [Making new Keras layers and models via subclassing](https://www.tensorflow.org/guide/keras/custom_layers_and_models)\n", |
401 | 401 | "\n", |
402 | 402 | "The following guides can assist with migrating distribution strategy workflows from `tf.estimator` APIs:\n", |
403 | 403 | "\n", |
|
0 commit comments