(vtab_key, image_size=224, query_size_limit=500)
return support_ds, query_ds, n_query, n_classes
This function reads VTAB-1k datasets as episodes.

  The training set becomes support set and the test is the query set.
  Query set size can be large and this could prevent evaluation without
  batching. Therefore we split the query set in to batches of size
  `query_size_limit`. In addition to these 2 datasets, the function returns
  total number of episodes(batches) after splitting the query set in
  `query_size_limit` batches.

  Args:
    vtab_key: str, one of constants.VTAB_DATASETS.
    image_size: int, used to resize the images read.
    query_size_limit: int, used to batch the query set.

  Returns:
    tf.data.Dataset, of support set in one batch.
    tf.data.Dataset, of query set in batches of size `query_size_limit`.
    int, number of batches available in the query set.
This function reads VTAB-1k datasets as episodes.
This function reads VTAB - 1k datasets as episodes .
def read_vtab_as_episode(vtab_key, image_size=224, query_size_limit=500):
  """This function reads VTAB-1k datasets as episodes.

  The training set becomes support set and the test is the query set.
  Query set size can be large and this could prevent evaluation without
  batching. Therefore we split the query set in to batches of size
  `query_size_limit`. In addition to these 2 datasets, the function returns
  total number of episodes(batches) after splitting the query set in
  `query_size_limit` batches.

  Args:
    vtab_key: str, one of constants.VTAB_DATASETS.
    image_size: int, used to resize the images read.
    query_size_limit: int, used to batch the query set.

  Returns:
    tf.data.Dataset, of support set in one batch.
    tf.data.Dataset, of query set in batches of size `query_size_limit`.
    int, number of batches available in the query set.
  """
  dataset_instance = data_loader.get_dataset_instance({
      "dataset": "data.%s" % vtab_key,
      "data_dir": None
  })
  query_ds = dataset_instance.get_tf_data(
      split_name="test",
      batch_size=query_size_limit,
      preprocess_fn=functools.partial(
          data_loader.preprocess_fn, input_range=(-1.0, 1.0), size=image_size),
      epochs=1,
      drop_remainder=False,
      for_eval=True,
      shuffle_buffer_size=0,
      prefetch=1,
  )
  n_query = math.ceil(
      dataset_instance.get_num_samples("test") / float(query_size_limit))
  support_ds = dataset_instance.get_tf_data(
      split_name="train800val200",
      # We get all 1000 images at once.
      batch_size=dataset_instance.get_num_samples("train800val200"),
      preprocess_fn=functools.partial(
          data_loader.preprocess_fn, input_range=(-1.0, 1.0), size=image_size),
      epochs=1,
      drop_remainder=False,
      for_eval=False,
      shuffle_buffer_size=0,
      prefetch=1,
  )
  n_classes = dataset_instance.get_num_classes()

  def cast_label_fn(ex):
    ex["label"] = tf.cast(ex["label"], tf.int32)
    return ex

  support_ds = support_ds.map(cast_label_fn)
  query_ds = query_ds.map(cast_label_fn)
  return support_ds, query_ds, n_query, n_classes
def read_vtab_as_episode ( vtab_key , image_size = 224 , query_size_limit = 500 ) : dataset_instance = data_loader . get_dataset_instance ( { "dataset" : "data.%s" % vtab_key , "data_dir" : None } ) query_ds = dataset_instance . get_tf_data ( split_name = "test" , batch_size = query_size_limit , preprocess_fn = functools . partial ( data_loader . preprocess_fn , input_range = ( - 1.0 , 1.0 ) , size = image_size ) , epochs = 1 , drop_remainder = False , for_eval = True , shuffle_buffer_size = 0 , prefetch = 1 , ) n_query = math . ceil ( dataset_instance . get_num_samples ( "test" ) / float ( query_size_limit ) ) support_ds = dataset_instance . get_tf_data ( split_name = "train800val200" , # We get all 1000 images at once. batch_size = dataset_instance . get_num_samples ( "train800val200" ) , preprocess_fn = functools . partial ( data_loader . preprocess_fn , input_range = ( - 1.0 , 1.0 ) , size = image_size ) , epochs = 1 , drop_remainder = False , for_eval = False , shuffle_buffer_size = 0 , prefetch = 1 , ) n_classes = dataset_instance . get_num_classes ( ) def cast_label_fn ( ex ) : ex [ "label" ] = tf . cast ( ex [ "label" ] , tf . int32 ) return ex support_ds = support_ds . map ( cast_label_fn ) query_ds = query_ds . map ( cast_label_fn ) return support_ds , query_ds , n_query , n_classes