def tower_loss(x, y, scope, reuse_variables=None):
    with tf.variable_scope(tf.get_variable_scope(), reuse=reuse_variables):
        v_len, output = net.build_arch(x, y, is_train=True)

    net.loss(v_len, output, x, y)

    loss = tf.get_collection(tf.GraphKeys.LOSSES, scope)[0]
    loss_name = re.sub('%s_[0-9]*/' % 'tower_', '', loss.op.name)
    tf.summary.scalar(loss_name, loss)

    return loss
def tower_loss(x, y, scope, reuse_variables=None):
    with tf.variable_scope(tf.get_variable_scope(), reuse=reuse_variables):
        v_len, output = net.build_arch(x, y, is_train=True)

    net.loss(v_len, output, x, y)

    loss = tf.get_collection(tf.GraphKeys.LOSSES, scope)[0]
    loss_name = re.sub('%s_[0-9]*/' % 'tower_', '', loss.op.name)
    tf.summary.scalar(loss_name, loss)

    return loss