MCPcopy Create free account
hub / github.com/tensorflow/models / run_experiment

Function run_experiment

official/core/train_lib.py:307–370  ·  view source on GitHub ↗

Runs train/eval configured by the experiment params. Args: distribution_strategy: A distribution 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

(
    distribution_strategy: tf.distribute.Strategy,
    task: base_task.Task,
    mode: str,
    params: config_definitions.ExperimentConfig,
    model_dir: str,
    run_post_eval: bool = False,
    save_summary: bool = True,
    train_actions: Optional[List[orbit.Action]] = None,
    eval_actions: Optional[List[orbit.Action]] = None,
    trainer: Optional[base_trainer.Trainer] = None,
    controller_cls=orbit.Controller,
    summary_manager: Optional[orbit.utils.SummaryManager] = None,
    eval_summary_manager: Optional[orbit.utils.SummaryManager] = None,
    enable_async_checkpointing: bool = False,
)

Source from the content-addressed store, hash-verified

305
306
307def run_experiment(
308 distribution_strategy: tf.distribute.Strategy,
309 task: base_task.Task,
310 mode: str,
311 params: config_definitions.ExperimentConfig,
312 model_dir: str,
313 run_post_eval: bool = False,
314 save_summary: bool = True,
315 train_actions: Optional[List[orbit.Action]] = None,
316 eval_actions: Optional[List[orbit.Action]] = None,
317 trainer: Optional[base_trainer.Trainer] = None,
318 controller_cls=orbit.Controller,
319 summary_manager: Optional[orbit.utils.SummaryManager] = None,
320 eval_summary_manager: Optional[orbit.utils.SummaryManager] = None,
321 enable_async_checkpointing: bool = False,
322) -> Tuple[tf_keras.Model, Mapping[str, Any]]:
323 """Runs train/eval configured by the experiment params.
324
325 Args:
326 distribution_strategy: A distribution distribution_strategy.
327 task: A Task instance.
328 mode: A 'str', specifying the mode. Can be 'train', 'eval', 'train_and_eval'
329 or 'continuous_eval'.
330 params: ExperimentConfig instance.
331 model_dir: A 'str', a path to store model checkpoints and summaries.
332 run_post_eval: Whether to run post eval once after training, metrics logs
333 are returned.
334 save_summary: Whether to save train and validation summary.
335 train_actions: Optional list of Orbit train actions.
336 eval_actions: Optional list of Orbit eval actions.
337 trainer: the base_trainer.Trainer instance. It should be created within the
338 strategy.scope().
339 controller_cls: The controller class to manage the train and eval process.
340 Must be a orbit.Controller subclass.
341 summary_manager: Instance of the summary manager to override default summary
342 manager.
343 eval_summary_manager: Instance of the eval summary manager to override
344 default eval summary manager.
345 enable_async_checkpointing: Optional boolean indicating whether to enable
346 async checkpoint saving.
347
348 Returns:
349 A 2-tuple of (model, eval_logs).
350 model: `tf_keras.Model` instance.
351 eval_logs: returns eval metrics logs when run_post_eval is set to True,
352 otherwise, returns {}.
353 """
354 runner = OrbitExperimentRunner(
355 distribution_strategy=distribution_strategy,
356 task=task,
357 mode=mode,
358 params=params,
359 model_dir=model_dir,
360 run_post_eval=run_post_eval,
361 save_summary=save_summary,
362 train_actions=train_actions,
363 eval_actions=eval_actions,
364 trainer=trainer,

Callers

nothing calls this directly

Calls 2

runMethod · 0.95

Tested by

no test coverage detected