research/improve_nas/trainer/cifar10.py [28:78]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try:
  from adanet.research.improve_nas.trainer import image_processing
except ImportError as e:
  from trainer import image_processing
# pylint: enable=g-import-not-at-top

FEATURES = 'x'
PreprocessingType = image_processing.PreprocessingType


class Provider(object):
  """A CIFAR-10 data provider."""

  def __init__(self,
               params_string='',
               seed=None):
    """Returns a CIFAR-10 `Provider`."""
    # For testing
    self._seed = seed
    default_params = tf.contrib.training.HParams(
        cutout=True, augmentation=PreprocessingType.BASIC)
    self._params = default_params.parse(params_string)

  def _preprocess_data(self, image, label, training, preprocess):
    """Apply Inception data augmentation and preprocessing."""

    # Unpack `Element` tuple.
    # image, label = element

    if preprocess:
      image_height, image_width = self._shape()[:2]
      if self._params.augmentation == PreprocessingType.BASIC:
        image = image_processing.resize_and_normalize(image, image_height,
                                                      image_width)
        if training:
          image = image_processing.basic_augmentation(image, image_height,
                                                      image_width, self._seed)
      else:
        raise ValueError('Unsupported data augmentation type: `%s`' %
                         self._params.augmentation)

      if training and self._params.cutout:
        # According to https://arxiv.org/abs/1708.04552, cutting out 16x16
        # works best.
        image = image_processing.cutout(image, pad_size=8, seed=self._seed)

    # Set shapes so that they are defined.
    image.set_shape(self._shape())
    if label is not None:
      label.set_shape([1])
    return {FEATURES: image}, label
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



research/improve_nas/trainer/cifar100.py [29:79]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
try:
  from adanet.research.improve_nas.trainer import image_processing
except ImportError as e:
  from trainer import image_processing
# pylint: enable=g-import-not-at-top

FEATURES = 'x'
PreprocessingType = image_processing.PreprocessingType


class Provider(object):
  """A CIFAR-100 data provider."""

  def __init__(self,
               params_string='',
               seed=None):
    """Returns a CIFAR-100 `Provider`."""
    # For testing
    self._seed = seed
    default_params = tf.contrib.training.HParams(
        cutout=True, augmentation=PreprocessingType.BASIC)
    self._params = default_params.parse(params_string)

  def _preprocess_data(self, image, label, training, preprocess):
    """Apply Inception data augmentation and preprocessing."""

    # Unpack `Element` tuple.
    # image, label = element

    if preprocess:
      image_height, image_width = self._shape()[:2]
      if self._params.augmentation == PreprocessingType.BASIC:
        image = image_processing.resize_and_normalize(image, image_height,
                                                      image_width)
        if training:
          image = image_processing.basic_augmentation(image, image_height,
                                                      image_width, self._seed)
      else:
        raise ValueError('Unsupported data augmentation type: `%s`' %
                         self._params.augmentation)

      if training and self._params.cutout:
        # According to https://arxiv.org/abs/1708.04552, cutting out 16x16
        # works best.
        image = image_processing.cutout(image, pad_size=8, seed=self._seed)

    # Set shapes so that they are defined.
    image.set_shape(self._shape())
    if label is not None:
      label.set_shape([1])
    return {FEATURES: image}, label
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



