Skip to content

Commit

Permalink
[air] Remove checkpoint user guide and update key concepts and docstr…
Browse files Browse the repository at this point in the history
  • Loading branch information
richardliaw authored Aug 4, 2022
1 parent 8d5c07b commit b2cd34c
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 309 deletions.
1 change: 0 additions & 1 deletion doc/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ parts:
- file: ray-air/user-guides
sections:
- file: ray-air/preprocessors
- file: ray-air/checkpoints
- file: ray-air/check-ingest
- file: ray-air/trainer
- file: ray-air/tuner
Expand Down
89 changes: 0 additions & 89 deletions doc/source/ray-air/checkpoints.rst

This file was deleted.

31 changes: 31 additions & 0 deletions doc/source/ray-air/doc_code/air_key_concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@
print(best_result)
# __air_tuner_end__

# __air_checkpoints_start__
checkpoint = result.checkpoint
print(checkpoint)
# Checkpoint(local_path=..../checkpoint_000005)

tuned_checkpoint = result_grid.get_best_result().checkpoint
print(tuned_checkpoint)
# Checkpoint(local_path=..../checkpoint_000005)
# __air_checkpoints_end__

# __checkpoint_adhoc_start__
from ray.train.tensorflow import TensorflowCheckpoint
import tensorflow as tf

# This can be a trained model.
def build_model() -> tf.keras.Model:
model = tf.keras.Sequential(
[
tf.keras.layers.InputLayer(input_shape=(1,)),
tf.keras.layers.Dense(1),
]
)
return model


model = build_model()

checkpoint = TensorflowCheckpoint.from_model(model)
# __checkpoint_adhoc_end__


# __air_batch_predictor_start__
from ray.train.batch_predictor import BatchPredictor
from ray.train.xgboost import XGBoostPredictor
Expand Down
122 changes: 0 additions & 122 deletions doc/source/ray-air/doc_code/checkpoint_usage.py

This file was deleted.

Binary file removed doc/source/ray-air/images/checkpoints.jpg
Binary file not shown.
36 changes: 32 additions & 4 deletions doc/source/ray-air/key-concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ See the documentation on :ref:`Trainers <air-trainers>`.
:start-after: __air_trainer_start__
:end-before: __air_trainer_end__



Trainer objects will produce a :ref:`Result <air-results-ref>` object after calling ``.fit()``. These objects will contain training metrics as long as checkpoints to retrieve the best model.
Trainer objects produce a :ref:`Result <air-results-ref>` object after calling ``.fit()``.
These objects contain training metrics as well as checkpoints to retrieve the best model.

.. literalinclude:: doc_code/air_key_concepts.py
:language: python
Expand All @@ -65,11 +64,40 @@ Tuners can work seamlessly with any Trainer but also can support arbitrary train
:start-after: __air_tuner_start__
:end-before: __air_tuner_end__

.. _air-checkpoints-doc:

Checkpoints
-----------

The AIR trainers, tuners, and custom pretrained model generate :class:`a framework-specific Checkpoint <ray.air.Checkpoint>` object.
Checkpoints are a common interface for models that are used across different AIR components and libraries.

There are two main ways to generate a checkpoint.

Checkpoint objects can be retrieved from the Result object returned by a Trainer or Tuner ``.fit()`` call.

.. literalinclude:: doc_code/air_key_concepts.py
:language: python
:start-after: __air_checkpoints_start__
:end-before: __air_checkpoints_end__

You can also generate a checkpoint from a pretrained model. Each AIR supported machine learning (ML) framework has
a ``Checkpoint`` object that can be used to generate an AIR checkpoint:

.. literalinclude:: doc_code/air_key_concepts.py
:language: python
:start-after: __checkpoint_adhoc_start__
:end-before: __checkpoint_adhoc_end__


Checkpoints can be used to instantiate a :class:`Predictor`, :class:`BatchPredictor`, or :class:`PredictorDeployment` classes,
as seen below.


Batch Predictor
---------------

You can take a trained model and do batch inference using the BatchPredictor object.
You can take a checkpoint and do batch inference using the BatchPredictor object.

.. literalinclude:: doc_code/air_key_concepts.py
:language: python
Expand Down
11 changes: 0 additions & 11 deletions doc/source/ray-air/user-guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ AIR User Guides
:text: Using Preprocessors
:classes: btn-link btn-block stretched-link


---
:img-top: /ray-overview/images/ray_svg_logo.svg

+++
.. link-button:: /ray-air/checkpoints
:type: ref
:text: Using Checkpoints
:classes: btn-link btn-block stretched-link


---
:img-top: /ray-overview/images/ray_svg_logo.svg

Expand Down
Loading

0 comments on commit b2cd34c

Please sign in to comment.