(loss, init_fn, hparams)
Wraps slim.learning.train to run a training loop.

  Args:
    loss: a loss tensor
    init_fn: A callable to be executed after all other initialization is done.
    hparams: a model hyper parameters
Wraps slim.learning.train to run a training loop.
Wraps slim . learning . train to run a training loop .
def train(loss, init_fn, hparams):
  """Wraps slim.learning.train to run a training loop.

  Args:
    loss: a loss tensor
    init_fn: A callable to be executed after all other initialization is done.
    hparams: a model hyper parameters
  """
  optimizer = create_optimizer(hparams)

  if FLAGS.sync_replicas:
    replica_id = tf.constant(FLAGS.task, tf.int32, shape=())
    optimizer = tf.LegacySyncReplicasOptimizer(
        opt=optimizer,
        replicas_to_aggregate=FLAGS.replicas_to_aggregate,
        replica_id=replica_id,
        total_num_replicas=FLAGS.total_num_replicas)
    sync_optimizer = optimizer
    startup_delay_steps = 0
  else:
    startup_delay_steps = 0
    sync_optimizer = None

  train_op = slim.learning.create_train_op(
      loss,
      optimizer,
      summarize_gradients=True,
      clip_gradient_norm=FLAGS.clip_gradient_norm)

  slim.learning.train(
      train_op=train_op,
      logdir=FLAGS.train_log_dir,
      graph=loss.graph,
      master=FLAGS.master,
      is_chief=(FLAGS.task == 0),
      number_of_steps=FLAGS.max_number_of_steps,
      save_summaries_secs=FLAGS.save_summaries_secs,
      save_interval_secs=FLAGS.save_interval_secs,
      startup_delay_steps=startup_delay_steps,
      sync_optimizer=sync_optimizer,
      init_fn=init_fn)
def train ( loss , init_fn , hparams ) : optimizer = create_optimizer ( hparams ) if FLAGS . sync_replicas : replica_id = tf . constant ( FLAGS . task , tf . int32 , shape = ( ) ) optimizer = tf . LegacySyncReplicasOptimizer ( opt = optimizer , replicas_to_aggregate = FLAGS . replicas_to_aggregate , replica_id = replica_id , total_num_replicas = FLAGS . total_num_replicas ) sync_optimizer = optimizer startup_delay_steps = 0 else : startup_delay_steps = 0 sync_optimizer = None train_op = slim . learning . create_train_op ( loss , optimizer , summarize_gradients = True , clip_gradient_norm = FLAGS . clip_gradient_norm ) slim . learning . train ( train_op = train_op , logdir = FLAGS . train_log_dir , graph = loss . graph , master = FLAGS . master , is_chief = ( FLAGS . task == 0 ) , number_of_steps = FLAGS . max_number_of_steps , save_summaries_secs = FLAGS . save_summaries_secs , save_interval_secs = FLAGS . save_interval_secs , startup_delay_steps = startup_delay_steps , sync_optimizer = sync_optimizer , init_fn = init_fn )