Ejemplo n.º 1
0
def convert_split_images(images, labels, train_validation_split=10):
    """Construct distorted input for CIFAR training using the Reader ops.

  Raises:
    ValueError: if labels and images count doesn't match.

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

  Returns:

  """
    # TODO complete doc
    assert images.shape[0] == labels.shape[0], "Number of images, %d should be equal to number of labels %d" % \
                                               (images.shape[0], labels.shape[0])

    validation_size = images.shape[
        0] * train_validation_split // 100  # default 10%

    # Generate a validation set.
    validation_images = images[:validation_size, :, :, :]
    validation_labels = labels[:validation_size]
    train_images = images[validation_size:, :, :, :]
    train_labels = labels[validation_size:]

    # Convert to Examples and write the result to TFRecords.
    convert_to_records.convert_to(train_images, train_labels, 'train')
    convert_to_records.convert_to(validation_images, validation_labels,
                                  'validation')
Ejemplo n.º 2
0
def convert_split_images(images, labels, train_validation_split=10):
    """Construct distorted input for CIFAR training using the Reader ops.

  Raises:
    ValueError: if labels and images count doesn't match.

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

  Returns:

  """
    # TODO complete doc
    assert images.shape[0] == labels.shape[0], "Number of images, %d should be equal to number of labels %d" % (
        images.shape[0],
        labels.shape[0],
    )

    validation_size = images.shape[0] * train_validation_split // 100  # default 10%

    # Generate a validation set.
    validation_images = images[:validation_size, :, :, :]
    validation_labels = labels[:validation_size]
    train_images = images[validation_size:, :, :, :]
    train_labels = labels[validation_size:]

    # Convert to Examples and write the result to TFRecords.
    convert_to_records.convert_to(train_images, train_labels, "train")
    convert_to_records.convert_to(validation_images, validation_labels, "validation")
Ejemplo n.º 3
0
def convert_images(images, labels, filename):
    """Construct distorted input for CIFAR training using the Reader ops.

  Raises:
    ValueError: if labels and images count doesn't match.

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

  Returns:

  """
    # TODO complete doc
    assert images.shape[0] == labels.shape[0], "Number of images, %d should be equal to number of labels %d" % \
                                               (images.shape[0], labels.shape[0])

    # Convert to Examples and write the result to TFRecords.
    convert_to_records.convert_to(images, labels, filename)
Ejemplo n.º 4
0
def convert_images(images, labels, filename):
    """Construct distorted input for CIFAR training using the Reader ops.

  Raises:
    ValueError: if labels and images count doesn't match.

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

  Returns:

  """
    # TODO complete doc
    assert images.shape[0] == labels.shape[0], "Number of images, %d should be equal to number of labels %d" % (
        images.shape[0],
        labels.shape[0],
    )

    # Convert to Examples and write the result to TFRecords.
    convert_to_records.convert_to(images, labels, filename)