In this guide, you’ll learn how to use the Keras API.
Visit the API reference
This document guides you through training a Keras model in Determined. You need to implement a trial
class that inherits
TFKerasTrial and specify it as the entrypoint in the
To learn about this API, you can start by reading the trial definitions from the following examples:
Before loading data, read Prepare Data to understand how to work with different sources of data.
Loading data is done by defining
build_validation_data_loader() methods. Each should return
one of the following data types:
(x, y)of Numpy arrays. x must be a NumPy array (or array-like), a list of arrays (in case the model has multiple inputs), or a dict mapping input names to the corresponding array, if the model has named inputs. y should be a numpy array.
(x, y, sample_weights)of Numpy arrays.
tf.data.datasetreturning a tuple of either (inputs, targets) or (inputs, targets, sample_weights).
keras.utils.Sequencereturning a tuple of either (inputs, targets) or (inputs, targets, sample weights).
tf.data.Dataset, users are required to wrap both their training and validation dataset
wrapper is used to shard the dataset for Distributed Training with Determined. For optimal performance, users
should wrap a dataset immediately after creating it.
Define the Model¶
Users are required wrap their model prior to compiling it using
self.context.wrap_model. This is typically done inside
Customize Calling Model Fitting Function¶
TFKerasTrial interface allows the user to configure how
is called by calling
A checkpoint includes the model definition (Python source code), experiment configuration file, network architecture, and the values of the model’s parameters (i.e., weights) and hyperparameters. When using a stateful optimizer during training, checkpoints will also include the state of the optimizer (i.e., learning rate). Users can also embed arbitrary metadata in checkpoints via a Python SDK.
TensorFlow Keras trials are checkpointed to a file named
tf.keras.models.save_model. You can learn more from the TF Keras docs.
To execute arbitrary Python code during the lifecycle of a
determined.keras.callbacks.Callback interface (an extension of the
tf.keras.callbacks.Callbacks interface) and supply them to the
TFKerasTrial by implementing