Attend the Women in ML Symposium on December 7 Register now

tfm.core.train_lib.OrbitExperimentRunner

Stay organized with collections Save and categorize content based on your preferences.

Runs experiment with Orbit training loop.

The default experiment runner for model garden experiments. User can customize the experiment pipeline by subclassing this class and replacing components or functions.

For example, an experiment runner with customized checkpoint manager:

class MyExpRunnerWithExporter(AbstractExperimentRunner):
  def _maybe_build_checkpoint_manager(sefl):
    return MyCheckpointManager(*args)

# In user code
MyExpRunnerWithExporter(**needed_kwargs).run(mode)

Similar override can be done to other components.

distribution_strategy A distribution strategy.
task A Task instance.
mode A 'str', specifying the mode. Can be 'train', 'eval', 'train_and_eval' or 'continuous_eval'.
params ExperimentConfig instance.
model_dir A 'str', a path to store model checkpoints and summaries.
run_post_eval Whether to run post eval once after training, metrics logs are returned.
save_summary Whether to save train and validation summary.
train_actions Optional list of Orbit train actions.
eval_actions Optional list of Orbit eval actions.
trainer the base_trainer.Trainer instance. It should be created within the strategy.scope().
controller_cls The controller class to manage the train and eval process. Must be a orbit.Controller subclass.

checkpoint_manager

controller

model_dir

params

trainer

Methods

run

View source

Run experiments by mode.

Returns
A 2-tuple of (model, eval_logs). model: tf.keras.Model instance. eval_logs: returns eval metrics logs when run_post_eval is set to True, otherwise, returns {}.