(images_per_class,
                                 num_remaining_per_class,
                                 support_set_size,
                                 min_log_weight,
                                 max_log_weight,
                                 rng=None)
return np.minimum(num_desired_per_class, num_remaining_per_class)
Samples the number of support examples per class.

  At a high level, we wish the composition to loosely match class frequencies.
  Sampling is done such that:

  * The number of support examples per class is no greater than
    `support_set_size`.
  * The number of support examples per class is no greater than the number of
    remaining examples per class after the query set has been taken into
    account.

  Args:
    images_per_class: np.array, number of images for each class.
    num_remaining_per_class: np.array, number of images available for each class
      after taking into account the number of query images.
    support_set_size: int, size of the support set in the episode.
    min_log_weight: float, minimum log-weight to give to any particular class.
    max_log_weight: float, maximum log-weight to give to any particular class.
    rng: np.random.RandomState used for sampling.

  Returns:
    num_support_per_class: np.array, number of support examples for each class.
Samples the number of support examples per class.
Samples the number of support examples per class .
def sample_num_support_per_class(images_per_class,
                                 num_remaining_per_class,
                                 support_set_size,
                                 min_log_weight,
                                 max_log_weight,
                                 rng=None):
  """Samples the number of support examples per class.

  At a high level, we wish the composition to loosely match class frequencies.
  Sampling is done such that:

  * The number of support examples per class is no greater than
    `support_set_size`.
  * The number of support examples per class is no greater than the number of
    remaining examples per class after the query set has been taken into
    account.

  Args:
    images_per_class: np.array, number of images for each class.
    num_remaining_per_class: np.array, number of images available for each class
      after taking into account the number of query images.
    support_set_size: int, size of the support set in the episode.
    min_log_weight: float, minimum log-weight to give to any particular class.
    max_log_weight: float, maximum log-weight to give to any particular class.
    rng: np.random.RandomState used for sampling.

  Returns:
    num_support_per_class: np.array, number of support examples for each class.
  """
  rng = rng or RNG
  if support_set_size < len(num_remaining_per_class):
    raise ValueError('Requesting smaller support set than the number of ways.')
  if np.min(num_remaining_per_class) < 1:
    raise ValueError('Some classes have no remaining examples.')

  # Remaining number of support examples to sample after we guarantee one
  # support example per class.
  remaining_support_set_size = support_set_size - len(num_remaining_per_class)

  unnormalized_proportions = images_per_class * np.exp(
      rng.uniform(min_log_weight, max_log_weight, size=images_per_class.shape))
  support_set_proportions = (
      unnormalized_proportions / unnormalized_proportions.sum())

  # This guarantees that there is at least one support example per class.
  num_desired_per_class = np.floor(
      support_set_proportions * remaining_support_set_size).astype('int32') + 1

  return np.minimum(num_desired_per_class, num_remaining_per_class)
def sample_num_support_per_class ( images_per_class , num_remaining_per_class , support_set_size , min_log_weight , max_log_weight , rng = None ) : rng = rng or RNG if support_set_size < len ( num_remaining_per_class ) : raise ValueError ( 'Requesting smaller support set than the number of ways.' ) if np . min ( num_remaining_per_class ) < 1 : raise ValueError ( 'Some classes have no remaining examples.' ) # Remaining number of support examples to sample after we guarantee one # support example per class. remaining_support_set_size = support_set_size - len ( num_remaining_per_class ) unnormalized_proportions = images_per_class * np . exp ( rng . uniform ( min_log_weight , max_log_weight , size = images_per_class . shape ) ) support_set_proportions = ( unnormalized_proportions / unnormalized_proportions . sum ( ) ) # This guarantees that there is at least one support example per class. num_desired_per_class = np . floor ( support_set_proportions * remaining_support_set_size ) . astype ( 'int32' ) + 1 return np . minimum ( num_desired_per_class , num_remaining_per_class )