Ejemplo n.º 1
0
def distorted_inputs(rank=0):
    """Construct distorted input for CIFAR training using the Reader ops.

    Returns:
      images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size.
      labels: Labels. 1D tensor of [batch_size] size.

    Raises:
      ValueError: If no data_dir
    """
    if not FLAGS.data_dir:
        raise ValueError('Please supply a data_dir')
    base_dir = FLAGS.data_dir + str(rank)
    if FLAGS.dataset == 'cifar10':
        data_dir = os.path.join(base_dir, 'cifar-10-batches-bin')
    else:
        data_dir = os.path.join(base_dir, 'cifar-100-binary')

    batch_size = FLAGS.batch_size
    images, labels = cifar_input.distorted_inputs(data_dir=data_dir,
                                                  batch_size=batch_size)
    if FLAGS.use_fp16:
        images = tf.cast(images, tf.float16)
        labels = tf.cast(labels, tf.float16)
    return images, labels
Ejemplo n.º 2
0
def get_distorted_train_batch(data_dir, batch_size):
    if not data_dir:
        raise ValueError('Please supply a data_dir')
    images, labels = cifar_input.distorted_inputs(cifar10or20or100=n_classes,
                                                  data_dir=data_dir,
                                                  batch_size=batch_size)
    return images, labels
Ejemplo n.º 3
0
def distorted_inputs():
    """Construct distorted input for CIFAR training using the Reader OPS.
        SOURCE: https://github.com/tensorflow/tensorflow/blob/r0.7/tensorflow/models/image/cifar10/cifar10.py"""

    if not FLAGS.data_dir:
        raise ValueError('Please supply a data_dir')
    data_dir = os.path.join(FLAGS.data_dir, 'cifar-10-batches-bin')
    return cifar_input.distorted_inputs(data_dir=data_dir,
                                        batch_size=FLAGS.batch_size)
Ejemplo n.º 4
0
def distorted_inputs(dataset_no):
    if not FLAGS.data_dir:
        raise ValueError('please supply a data_dir')
    if dataset_no == '10':
        data_dir = os.path.join(FLAGS.data_dir, 'cifar-10-batches-bin')
    else:
        data_dir = os.path.join(FLAGS.data_dir, 'cifar-100-binary')
    return cifar_input.distorted_inputs(dataset_no,
                                        data_dir=data_dir,
                                        batch_size=FLAGS.batch_size)
Ejemplo n.º 5
0
def distorted_inputs(dataset_no):
    if not FLAGS.data_dir:
        raise ValueError('please supply a data_dir')
    if dataset_no == '10':
        data_dir = os.path.join(FLAGS.data_dir, 'cifar-10-batches-bin')
    else:
        data_dir = os.path.join(FLAGS.data_dir, 'cifar-100-binary')
    return cifar_input.distorted_inputs(dataset_no,
                                        data_dir=data_dir,
                                        batch_size=FLAGS.batch_size)
def get_distorted_train_batch(data_dir, batch_size):
    """
    :param data_dir:
    :param batch_size:
    :return: images 4D Tensor of [batch_size, image_size,image_size,3] size
             labels 1D Tensor of [batch_size] size
    """
    if not data_dir:
        raise ValueError('please supply a data_dir')
    images, labels = cifar_input.distorted_inputs(cifar10or20or100=n_classes,
                                                  data_dir=data_dir,
                                                  batch_size=batch_size)
    return images, labels  # 返回batch_size=100批次的样本
Ejemplo n.º 7
0
def distorted_inputs(is_cifar10):
    """Construct distorted input for CIFAR training using the Reader ops.

    Returns:
        images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size.
        labels: Labels. 1D tensor of [batch_size] size.

    Raises:
        ValueError: If no data_dir
    """
    FLAGS = parser.parse_args()
    if not FLAGS.data_dir:
        raise ValueError('Please supply a data_dir')
    data_dir = os.path.join(FLAGS.data_dir, '%s-binary' % (FLAGS.dataset))
    images, labels = cifar_input.distorted_inputs(data_dir=data_dir,
                                                  batch_size=FLAGS.batch_size,
                                                  is_cifar10=is_cifar10)
    return images, labels
Ejemplo n.º 8
0
def get_distorted_train_batch(cifar10or20or100, data_dir, batch_size):
    """Construct distorted input for CIFAR training using the Reader ops.

      Returns:
        images: Images. 4D tensor of [batch_size, IMAGE_SIZE, IMAGE_SIZE, 3] size.
        labels: Labels. 1D tensor of [batch_size] size.

      Raises:
        ValueError: If no data_dir
      """
    if not data_dir:
        raise ValueError('Please supply a data_dir')
    if cifar10or20or100 == 10:
        data_dir = os.path.join(data_dir, 'cifar-10-batches-bin')
    else:
        data_dir = os.path.join(data_dir, 'cifar-100-binary')
    images, labels = cifar_input.distorted_inputs(
        cifar10or20or100=cifar10or20or100,
        data_dir=data_dir,
        batch_size=batch_size)
    return images, labels