Runs a training loop using a TensorFlow supervisor. When the sync_optimizer is supplied, gradient updates are applied synchronously. Otherwise, gradient updates are applied asynchronous. Args: train_op: A `Tensor` that, when executed, will apply the gradients and return the loss va
(train_op,
logdir,
train_step_fn=train_step,
train_step_kwargs=_USE_DEFAULT,
log_every_n_steps=1,
graph=None,
master='',
is_chief=True,
global_step=None,
number_of_steps=None,
init_op=_USE_DEFAULT,
init_feed_dict=None,
local_init_op=_USE_DEFAULT,
init_fn=None,
ready_op=_USE_DEFAULT,
summary_op=_USE_DEFAULT,
save_summaries_secs=600,
summary_writer=_USE_DEFAULT,
startup_delay_steps=0,
saver=None,
save_interval_secs=600,
sync_optimizer=None,
session_config=None,
session_wrapper=None,
trace_every_n_steps=None,
ignore_live_threads=False)
| 531 | |
| 532 | |
| 533 | def train(train_op, |
| 534 | logdir, |
| 535 | train_step_fn=train_step, |
| 536 | train_step_kwargs=_USE_DEFAULT, |
| 537 | log_every_n_steps=1, |
| 538 | graph=None, |
| 539 | master='', |
| 540 | is_chief=True, |
| 541 | global_step=None, |
| 542 | number_of_steps=None, |
| 543 | init_op=_USE_DEFAULT, |
| 544 | init_feed_dict=None, |
| 545 | local_init_op=_USE_DEFAULT, |
| 546 | init_fn=None, |
| 547 | ready_op=_USE_DEFAULT, |
| 548 | summary_op=_USE_DEFAULT, |
| 549 | save_summaries_secs=600, |
| 550 | summary_writer=_USE_DEFAULT, |
| 551 | startup_delay_steps=0, |
| 552 | saver=None, |
| 553 | save_interval_secs=600, |
| 554 | sync_optimizer=None, |
| 555 | session_config=None, |
| 556 | session_wrapper=None, |
| 557 | trace_every_n_steps=None, |
| 558 | ignore_live_threads=False): |
| 559 | """Runs a training loop using a TensorFlow supervisor. |
| 560 | |
| 561 | When the sync_optimizer is supplied, gradient updates are applied |
| 562 | synchronously. Otherwise, gradient updates are applied asynchronous. |
| 563 | |
| 564 | Args: |
| 565 | train_op: A `Tensor` that, when executed, will apply the gradients and |
| 566 | return the loss value. |
| 567 | logdir: The directory where training logs are written to. If None, model |
| 568 | checkpoints and summaries will not be written. |
| 569 | train_step_fn: The function to call in order to execute a single gradient |
| 570 | step. The function must have take exactly four arguments: the current |
| 571 | session, the `train_op` `Tensor`, a global step `Tensor` and a |
| 572 | dictionary. |
| 573 | train_step_kwargs: A dictionary which is passed to the `train_step_fn`. By |
| 574 | default, two `Boolean`, scalar ops called "should_stop" and "should_log" |
| 575 | are provided. |
| 576 | log_every_n_steps: The frequency, in terms of global steps, that the loss |
| 577 | and global step are logged. |
| 578 | graph: The graph to pass to the supervisor. If no graph is supplied the |
| 579 | default graph is used. |
| 580 | master: The address of the tensorflow master. |
| 581 | is_chief: Specifies whether or not the training is being run by the primary |
| 582 | replica during replica training. |
| 583 | global_step: The `Tensor` representing the global step. If left as `None`, |
| 584 | then training_util.get_or_create_global_step(), that is, |
| 585 | tf.contrib.framework.global_step() is used. |
| 586 | number_of_steps: The max number of gradient steps to take during training, |
| 587 | as measured by 'global_step': training will stop if global_step is greater |
| 588 | than 'number_of_steps'. If the value is left as None, training proceeds |
| 589 | indefinitely. |
| 590 | init_op: The initialization operation. If left to its default value, then |
nothing calls this directly
no test coverage detected