(class_props, logits, targets)
return imbalance_to_accuracy
Accuracy as a function of imabalance.

  Args:
    class_props: A list containing a np.array per episode. The shape of an
      episode's array is the [way]. Stores the 'normalized shot' of each class,
      ie. the proportion of the examples of that class that are in the support
      set of the episode.
    logits: A list containing a np.array per episode. The shape of an episode's
      array is [size of test set, way].
    targets: A list containing a np.array per episode. The shape of an episode's
      array is [size of test set]. This contains integers in the range from 0 to
      the way of the episode.

  Returns:
    imbalance_to_accuracy: A dict mapping each observed imbalance (a float) to a
    list that stores the accuracy of the episodes characterized by that degree
    of imbalance.

  Raises:
    ValueError: There should have been exactly 2 elements in the list of each
      episode's class id's.
Accuracy as a function of imabalance.
Accuracy as a function of imabalance .
def get_imbalance_to_accuracy(class_props, logits, targets):
  """Accuracy as a function of imabalance.

  Args:
    class_props: A list containing a np.array per episode. The shape of an
      episode's array is the [way]. Stores the 'normalized shot' of each class,
      ie. the proportion of the examples of that class that are in the support
      set of the episode.
    logits: A list containing a np.array per episode. The shape of an episode's
      array is [size of test set, way].
    targets: A list containing a np.array per episode. The shape of an episode's
      array is [size of test set]. This contains integers in the range from 0 to
      the way of the episode.

  Returns:
    imbalance_to_accuracy: A dict mapping each observed imbalance (a float) to a
    list that stores the accuracy of the episodes characterized by that degree
    of imbalance.

  Raises:
    ValueError: There should have been exactly 2 elements in the list of each
      episode's class id's.
  """
  imbalance_to_accuracy = collections.defaultdict(list)
  for episode_num, episode_class_props in enumerate(class_props):
    if len(episode_class_props) != 2:
      raise ValueError(
          'There should have been exactly 2 elements in the list '
          "of each episode's class_props (we only perform the "
          'imbalance analysis on binary tasks). Instead, found: {}'.format(
              len(episode_class_props)))
    # Compute imbalance.
    imbalance = max(episode_class_props) - min(episode_class_props)
    # Compute the accuracy of the episode.
    episode_logits = logits[episode_num]
    episode_targets = targets[episode_num]
    episode_acc = compute_episode_accuracy(episode_logits, episode_targets)
    imbalance_to_accuracy[imbalance].append(episode_acc)
  return imbalance_to_accuracy
def get_imbalance_to_accuracy ( class_props , logits , targets ) : imbalance_to_accuracy = collections . defaultdict ( list ) for episode_num , episode_class_props in enumerate ( class_props ) : if len ( episode_class_props ) != 2 : raise ValueError ( 'There should have been exactly 2 elements in the list ' "of each episode's class_props (we only perform the " 'imbalance analysis on binary tasks). Instead, found: {}' . format ( len ( episode_class_props ) ) ) # Compute imbalance. imbalance = max ( episode_class_props ) - min ( episode_class_props ) # Compute the accuracy of the episode. episode_logits = logits [ episode_num ] episode_targets = targets [ episode_num ] episode_acc = compute_episode_accuracy ( episode_logits , episode_targets ) imbalance_to_accuracy [ imbalance ] . append ( episode_acc ) return imbalance_to_accuracy