// moving average operation
variable_averages = tf.train.ExponentialMovingAverage(0.9)
trainables = tf.trainable_variables()
moving_ave_op = variable_averages.apply(trainables)
// training operation
if self.is_training:
updates_op = [moving_ave_op]
updates_op.extend(bn_ops) if bn_ops is not None else None
with graph.control_dependencies(updates_op):
averaged_grads = gradients_collector.average_gradients()
self.app.set_network_update_op(averaged_grads)
// assigning output variables back to each application
self.app.set_all_output_ops([net_outputs, tf.global_variables()])
After Change
if not mva_op.type == "NoOp":
updates_op.extend(mva_op)
// batch normalisation moving averages operation
if bn_ops is not None and len(bn_ops) > 0:
updates_op.extend(bn_ops)
// combine them with model parameter updating operation
with graph.control_dependencies(updates_op):