(embeddings, labels)
return prototypes
Computes class prototypes over the last dimension of embeddings.

  Args:
    embeddings: Tensor of examples of shape [num_examples, embedding_size].
    labels: Tensor of one-hot encoded labels of shape [num_examples,
      num_classes].

  Returns:
    prototypes: Tensor of class prototypes of shape [num_classes,
    embedding_size].
Computes class prototypes over the last dimension of embeddings.
Computes class prototypes over the last dimension of embeddings .
def _compute_prototypes(embeddings, labels):
  """Computes class prototypes over the last dimension of embeddings.

  Args:
    embeddings: Tensor of examples of shape [num_examples, embedding_size].
    labels: Tensor of one-hot encoded labels of shape [num_examples,
      num_classes].

  Returns:
    prototypes: Tensor of class prototypes of shape [num_classes,
    embedding_size].
  """
  labels = tf.cast(labels, tf.float32)

  # [num examples, 1, embedding size].
  embeddings = tf.expand_dims(embeddings, 1)

  # [num examples, num classes, 1].
  labels = tf.expand_dims(labels, 2)

  # Sums each class' embeddings. [num classes, embedding size].
  class_sums = tf.reduce_sum(labels * embeddings, 0)

  # The prototype of each class is the averaged embedding of its examples.
  class_num_images = tf.reduce_sum(labels, 0)  # [way].
  prototypes = class_sums / class_num_images

  return prototypes
def _compute_prototypes ( embeddings , labels ) : labels = tf . cast ( labels , tf . float32 ) # [num examples, 1, embedding size]. embeddings = tf . expand_dims ( embeddings , 1 ) # [num examples, num classes, 1]. labels = tf . expand_dims ( labels , 2 ) # Sums each class' embeddings. [num classes, embedding size]. class_sums = tf . reduce_sum ( labels * embeddings , 0 ) # The prototype of each class is the averaged embedding of its examples. class_num_images = tf . reduce_sum ( labels , 0 ) # [way]. prototypes = class_sums / class_num_images return prototypes