code: def center_loss(embedding, label, num_classes, alpha=0.1, scope="center_loss"):
      r
      nrof_features = embedding.get_shape()[1]
      centers = tf.get_variable('centers', [num_classes, nrof_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 - embedding)
      centers = tf.scatter_sub(centers, label, diff)
      loss = tf.reduce_mean(tf.square(embedding - centers_batch), name=scope)
      return loss
docs: r"""Center-Loss as described in the paper
      `A Discriminative Feature Learning Approach for Deep Face Recognition`
      <http://ydwen.github.io/papers/WenECCV16.pdf> by Wen et al.
  
      Args:
          embedding (tf.Tensor): features produced by the network
          label (tf.Tensor): ground-truth label for each feature
          num_classes (int): number of different classes
          alpha (float): learning rate for updating the centers
  
      Returns:
          tf.Tensor: center loss