def tower_loss(scope):
 (images, labels) = cifar10.distorted_inputs()
 logits = cifar10.inference(images)
 _ = cifar10.loss(logits, labels)
 losses = tf.get_collection('losses', scope)
 total_loss = tf.add_n(losses, name='total_loss')
 for l in (losses + [total_loss]):
  loss_name = re.sub(('%s_[0-9]*/' % cifar10.TOWER_NAME), '', l.op.name)
  tf.scalar_summary(loss_name, l)
 return total_loss

def tower_loss ( scope ) : ( images , labels ) = cifar10 . distorted_inputs ( ) logits = cifar10 . inference ( images ) _ = cifar10 . loss ( logits , labels ) losses = tf . get_collection ( 'losses' , scope ) total_loss = tf . add_n ( losses , name = 'total_loss' ) for l in ( losses + [ total_loss ] ) : loss_name = re . sub ( ( '%s_[0-9]*/' % cifar10 . TOWER_NAME ) , '' , l . op . name ) tf . scalar_summary ( loss_name , l ) return total_loss
calculate the total loss on a single tower running the cifar model .