(example_strings, class_ids, chunk_sizes, image_size,
                    support_decoder, query_decoder, simclr_episode_fraction)
return episode
Processes an episode.

  This function:

  1) splits the batch of examples into "flush", "support", and "query" chunks,
  2) throws away the "flush" chunk,
  3) removes the padded placeholder examples from the "support" and "query"
     chunks,
  4) extracts and processes images out of the example strings, and
  5) builds support and query targets (numbers from 0 to K-1 where K is the
     number of classes in the episode) from the class IDs.

  Args:
    example_strings: 1-D Tensor of dtype str, tf.train.Example protocol buffers.
    class_ids: 1-D Tensor of dtype int, class IDs (absolute wrt the original
      dataset).
    chunk_sizes: Tuple of ints representing the sizes the flush and additional
      chunks.
    image_size: int, desired image size used during decoding.
    support_decoder: Decoder, used to decode support set images. If
      None, no decoding of support images is performed.
    query_decoder: Decoder, used to decode query set images. If
      None, no decoding of query images is performed.
    simclr_episode_fraction: Fraction of episodes to convert to SimCLR episodes.

  Returns:
    support_images, support_labels, support_class_ids, query_images,
      query_labels, query_class_ids: Tensors, batches of images, labels, and
      (absolute) class IDs, for the support and query sets (respectively).
      Example proto buffers are returned in place of images if the corresponding
      decoder is None.
Processes an episode.
Processes an episode .
def process_episode(example_strings, class_ids, chunk_sizes, image_size,
                    support_decoder, query_decoder, simclr_episode_fraction):
  """Processes an episode.

  This function:

  1) splits the batch of examples into "flush", "support", and "query" chunks,
  2) throws away the "flush" chunk,
  3) removes the padded placeholder examples from the "support" and "query"
     chunks,
  4) extracts and processes images out of the example strings, and
  5) builds support and query targets (numbers from 0 to K-1 where K is the
     number of classes in the episode) from the class IDs.

  Args:
    example_strings: 1-D Tensor of dtype str, tf.train.Example protocol buffers.
    class_ids: 1-D Tensor of dtype int, class IDs (absolute wrt the original
      dataset).
    chunk_sizes: Tuple of ints representing the sizes the flush and additional
      chunks.
    image_size: int, desired image size used during decoding.
    support_decoder: Decoder, used to decode support set images. If
      None, no decoding of support images is performed.
    query_decoder: Decoder, used to decode query set images. If
      None, no decoding of query images is performed.
    simclr_episode_fraction: Fraction of episodes to convert to SimCLR episodes.

  Returns:
    support_images, support_labels, support_class_ids, query_images,
      query_labels, query_class_ids: Tensors, batches of images, labels, and
      (absolute) class IDs, for the support and query sets (respectively).
      Example proto buffers are returned in place of images if the corresponding
      decoder is None.

  """
  # TODO(goroshin): Replace with `support_decoder.log_summary(name='support')`.
  # TODO(goroshin): Eventually remove setting the image size here and pass it
  # to the ImageDecoder constructor instead.
  if isinstance(support_decoder, decoder.ImageDecoder):
    log_data_augmentation(support_decoder.data_augmentation, 'support')
    support_decoder.image_size = image_size
  if isinstance(query_decoder, decoder.ImageDecoder):
    log_data_augmentation(query_decoder.data_augmentation, 'query')
    query_decoder.image_size = image_size

  (support_strings, support_class_ids), (query_strings, query_class_ids) = \
      flush_and_chunk_episode(example_strings, class_ids, chunk_sizes)

  support_images = support_strings
  query_images = query_strings

  if support_decoder:
    support_images = tf.map_fn(
        support_decoder,
        support_strings,
        dtype=support_decoder.out_type,
        back_prop=False)
  if query_decoder:
    query_images = tf.map_fn(
        query_decoder,
        query_strings,
        dtype=query_decoder.out_type,
        back_prop=False)

  # Convert class IDs into labels in [0, num_ways).
  _, support_labels = tf.unique(support_class_ids)
  _, query_labels = tf.unique(query_class_ids)

  episode = (support_images, support_labels, support_class_ids, query_images,
             query_labels, query_class_ids)

  if simclr_episode_fraction > 0.0:
    episode = add_simclr_episodes(simclr_episode_fraction, *episode)

  return episode
def process_episode ( example_strings , class_ids , chunk_sizes , image_size , support_decoder , query_decoder , simclr_episode_fraction ) : # TODO(goroshin): Replace with `support_decoder.log_summary(name='support')`. # TODO(goroshin): Eventually remove setting the image size here and pass it # to the ImageDecoder constructor instead. if isinstance ( support_decoder , decoder . ImageDecoder ) : log_data_augmentation ( support_decoder . data_augmentation , 'support' ) support_decoder . image_size = image_size if isinstance ( query_decoder , decoder . ImageDecoder ) : log_data_augmentation ( query_decoder . data_augmentation , 'query' ) query_decoder . image_size = image_size ( support_strings , support_class_ids ) , ( query_strings , query_class_ids ) = flush_and_chunk_episode ( example_strings , class_ids , chunk_sizes ) support_images = support_strings query_images = query_strings if support_decoder : support_images = tf . map_fn ( support_decoder , support_strings , dtype = support_decoder . out_type , back_prop = False ) if query_decoder : query_images = tf . map_fn ( query_decoder , query_strings , dtype = query_decoder . out_type , back_prop = False ) # Convert class IDs into labels in [0, num_ways). _ , support_labels = tf . unique ( support_class_ids ) _ , query_labels = tf . unique ( query_class_ids ) episode = ( support_images , support_labels , support_class_ids , query_images , query_labels , query_class_ids ) if simclr_episode_fraction > 0.0 : episode = add_simclr_episodes ( simclr_episode_fraction , * episode ) return episode