def train_op_fun(total_loss, global_step):
 nb_ex_per_train_epoch = int((60000 / FLAGS.nb_teachers))
 num_batches_per_epoch = (nb_ex_per_train_epoch / FLAGS.batch_size)
 decay_steps = int((num_batches_per_epoch * FLAGS.epochs_per_decay))
 initial_learning_rate = (float(FLAGS.learning_rate) / 100.0)
 lr = tf.train.exponential_decay(initial_learning_rate, global_step, decay_steps, LEARNING_RATE_DECAY_FACTOR, staircase=True)
 tf.scalar_summary('learning_rate', lr)
 loss_averages_op = moving_av(total_loss)
 with tf.control_dependencies([loss_averages_op]):
  opt = tf.train.GradientDescentOptimizer(lr)
  grads = opt.compute_gradients(total_loss)
 apply_gradient_op = opt.apply_gradients(grads, global_step=global_step)
 for var in tf.trainable_variables():
  tf.histogram_summary(var.op.name, var)
 variable_averages = tf.train.ExponentialMovingAverage(MOVING_AVERAGE_DECAY, global_step)
 variables_averages_op = variable_averages.apply(tf.trainable_variables())
 with tf.control_dependencies([apply_gradient_op, variables_averages_op]):
  train_op = tf.no_op(name='train')
 return train_op

def train_op_fun ( total_loss , global_step ) : nb_ex_per_train_epoch = int ( ( 60000 / FLAGS . nb_teachers ) ) num_batches_per_epoch = ( nb_ex_per_train_epoch / FLAGS . batch_size ) decay_steps = int ( ( num_batches_per_epoch * FLAGS . epochs_per_decay ) ) initial_learning_rate = ( float ( FLAGS . learning_rate ) / 100.0 ) lr = tf . train . exponential_decay ( initial_learning_rate , global_step , decay_steps , LEARNING_RATE_DECAY_FACTOR , staircase = True ) tf . scalar_summary ( 'learning_rate' , lr ) loss_averages_op = moving_av ( total_loss ) with tf . control_dependencies ( [ loss_averages_op ] ) : opt = tf . train . GradientDescentOptimizer ( lr ) grads = opt . compute_gradients ( total_loss ) apply_gradient_op = opt . apply_gradients ( grads , global_step = global_step ) for var in tf . trainable_variables ( ) : tf . histogram_summary ( var . op . name , var ) variable_averages = tf . train . ExponentialMovingAverage ( MOVING_AVERAGE_DECAY , global_step ) variables_averages_op = variable_averages . apply ( tf . trainable_variables ( ) ) with tf . control_dependencies ( [ apply_gradient_op , variables_averages_op ] ) : train_op = tf . no_op ( name = 'train' ) return train_op
train model .