(images_per_class, max_num_query, num_support)
return np.minimum(max_num_query, images_per_class.min() - max_support)
Computes the number of query examples per class in the episode.

  Query sets are balanced, i.e., contain the same number of examples for each
  class in the episode.

  The number of query examples satisfies the following conditions:
  - it is no greater than `max_num_query`
  - if support size is unspecified, it is at most half the size of the
    smallest class in the episode
  - if support size is specified, it is at most the size of the smallest class
    in the episode minus the max support size.

  Args:
    images_per_class: np.array, number of images for each class.
    max_num_query: int, number of images for each class.
    num_support: int or tuple(int, int), number (or range) of support
      images per class.

  Returns:
    num_query: int, number of query examples per class in the episode.
Computes the number of query examples per class in the episode.
Computes the number of query examples per class in the episode .
def compute_num_query(images_per_class, max_num_query, num_support):
  """Computes the number of query examples per class in the episode.

  Query sets are balanced, i.e., contain the same number of examples for each
  class in the episode.

  The number of query examples satisfies the following conditions:
  - it is no greater than `max_num_query`
  - if support size is unspecified, it is at most half the size of the
    smallest class in the episode
  - if support size is specified, it is at most the size of the smallest class
    in the episode minus the max support size.

  Args:
    images_per_class: np.array, number of images for each class.
    max_num_query: int, number of images for each class.
    num_support: int or tuple(int, int), number (or range) of support
      images per class.

  Returns:
    num_query: int, number of query examples per class in the episode.
  """
  if num_support is None:
    if images_per_class.min() < 2:
      raise ValueError('Expected at least 2 images per class.')
    return np.minimum(max_num_query, (images_per_class // 2).min())
  elif isinstance(num_support, int):
    max_support = num_support
  else:
    _, max_support = num_support
  if (images_per_class - max_support).min() < 1:
    raise ValueError(
        'Expected at least {} images per class'.format(max_support + 1))
  return np.minimum(max_num_query, images_per_class.min() - max_support)
def compute_num_query ( images_per_class , max_num_query , num_support ) : if num_support is None : if images_per_class . min ( ) < 2 : raise ValueError ( 'Expected at least 2 images per class.' ) return np . minimum ( max_num_query , ( images_per_class // 2 ) . min ( ) ) elif isinstance ( num_support , int ) : max_support = num_support else : _ , max_support = num_support if ( images_per_class - max_support ) . min ( ) < 1 : raise ValueError ( 'Expected at least {} images per class' . format ( max_support + 1 ) ) return np . minimum ( max_num_query , images_per_class . min ( ) - max_support )