import tensorflow as tf


    grl = fc(grl, 100, True, None, activation=relu, name='fc1')
    logits = fc(grl, 1, True, None, activation=None, name='fc2')

    domain_predictions = tf.sigmoid(logits)

  domain_loss = tf.losses.log_loss(domain_selection_mask, domain_predictions, weights=weight)

  domain_accuracy = util.accuracy_tf(domain_selection_mask, tf.round(domain_predictions))

  assert_op = tf.Assert(tf.is_finite(domain_loss), [domain_loss])
  with tf.control_dependencies([assert_op]):
    tag_loss = 'losses/domain_loss'
    barrier = tf.no_op(tag_loss)

  return domain_loss


def difference_loss(private_samples, shared_samples, weight=1.0, name='difference_loss'):
  """Adds the difference loss between the private and shared representations.

  Args:
    private_samples: a tensor of shape [num_samples, num_features].
    shared_samples: a tensor of shape [num_samples, num_features].
    weight: the weight of the incoherence loss.
    name: the name of the tf summary.
