import tensorflow as tf

    num_features = features.get_shape()[1]
    centers = tf.get_variable(
        'centers', [num_classes, num_features],
        dtype=tf.float32,
        initializer=tf.constant_initializer(0),
        trainable=False)
    label = tf.reshape(label, [-1])
    centers_batch = tf.gather(centers, label)
    diff = (1 - alpha) * (centers_batch - features)
    centers = tf.scatter_sub(centers, label, diff)
    loss = tf.nn.l2_loss(features - centers_batch)
    return loss, centers


def correlation_loss(source_samples, target_samples, weight, name='corr_loss'):
  """Adds a similarity loss term, the correlation between two representations.

  Args:
      source_samples: a tensor of shape [num_samples, num_features]
      target_samples: a tensor of shape [num_samples, num_features]
