Make and run an experiment. It creates an Experiment by calling `experiment_fn`. Then it calls the function named as `schedule` of the Experiment. If schedule is not provided, then the default schedule for the current task type is used. The defaults are as follows: * 'ps' maps to 'serv
(experiment_fn, output_dir=None, schedule=None, run_config=None,
hparams=None)
| 107 | |
| 108 | @deprecated(None, 'Use tf.estimator.train_and_evaluate.') |
| 109 | def run(experiment_fn, output_dir=None, schedule=None, run_config=None, |
| 110 | hparams=None): |
| 111 | """Make and run an experiment. |
| 112 | |
| 113 | It creates an Experiment by calling `experiment_fn`. Then it calls the |
| 114 | function named as `schedule` of the Experiment. |
| 115 | |
| 116 | If schedule is not provided, then the default schedule for the current task |
| 117 | type is used. The defaults are as follows: |
| 118 | |
| 119 | * 'ps' maps to 'serve' |
| 120 | * 'worker' maps to 'train' |
| 121 | * 'master' maps to 'local_run' |
| 122 | |
| 123 | If the experiment's config does not include a task type, then an exception |
| 124 | is raised. |
| 125 | |
| 126 | Example with `run_config` (Recommended): |
| 127 | ``` |
| 128 | def _create_my_experiment(run_config, hparams): |
| 129 | |
| 130 | # You can change a subset of the run_config properties as |
| 131 | # run_config = run_config.replace(save_checkpoints_steps=500) |
| 132 | |
| 133 | return tf.contrib.learn.Experiment( |
| 134 | estimator=my_estimator(config=run_config, hparams=hparams), |
| 135 | train_input_fn=my_train_input, |
| 136 | eval_input_fn=my_eval_input) |
| 137 | |
| 138 | learn_runner.run( |
| 139 | experiment_fn=_create_my_experiment, |
| 140 | run_config=run_config_lib.RunConfig(model_dir="some/output/dir"), |
| 141 | schedule="train_and_evaluate", |
| 142 | hparams=_create_default_hparams()) |
| 143 | ``` |
| 144 | or simply as |
| 145 | ``` |
| 146 | learn_runner.run( |
| 147 | experiment_fn=_create_my_experiment, |
| 148 | run_config=run_config_lib.RunConfig(model_dir="some/output/dir")) |
| 149 | ``` |
| 150 | if `hparams` is not used by the `Estimator`. On a single machine, `schedule` |
| 151 | defaults to `train_and_evaluate`. |
| 152 | |
| 153 | Example with `output_dir` (deprecated): |
| 154 | ``` |
| 155 | def _create_my_experiment(output_dir): |
| 156 | return tf.contrib.learn.Experiment( |
| 157 | estimator=my_estimator(model_dir=output_dir), |
| 158 | train_input_fn=my_train_input, |
| 159 | eval_input_fn=my_eval_input) |
| 160 | |
| 161 | learn_runner.run( |
| 162 | experiment_fn=_create_my_experiment, |
| 163 | output_dir="some/output/dir", |
| 164 | schedule="train") |
| 165 | ``` |
| 166 | Args: |