當前位置: 首頁>>代碼示例>>Python>>正文


Python dataset.Dataset方法代碼示例

本文整理匯總了Python中tensorflow.contrib.slim.python.slim.data.dataset.Dataset方法的典型用法代碼示例。如果您正苦於以下問題:Python dataset.Dataset方法的具體用法?Python dataset.Dataset怎麽用?Python dataset.Dataset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.slim.python.slim.data.dataset的用法示例。


在下文中一共展示了dataset.Dataset方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _create_tfrecord_dataset

# 需要導入模塊: from tensorflow.contrib.slim.python.slim.data import dataset [as 別名]
# 或者: from tensorflow.contrib.slim.python.slim.data.dataset import Dataset [as 別名]
def _create_tfrecord_dataset(tmpdir):
  if not gfile.Exists(tmpdir):
    gfile.MakeDirs(tmpdir)

  data_sources = test_utils.create_tfrecord_files(tmpdir, num_files=1)

  keys_to_features = {
      'image/encoded':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value=''),
      'image/format':
          parsing_ops.FixedLenFeature(
              shape=(), dtype=dtypes.string, default_value='jpeg'),
      'image/class/label':
          parsing_ops.FixedLenFeature(
              shape=[1],
              dtype=dtypes.int64,
              default_value=array_ops.zeros(
                  [1], dtype=dtypes.int64))
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(keys_to_features,
                                               items_to_handlers)

  return dataset.Dataset(
      data_sources=data_sources,
      reader=io_ops.TFRecordReader,
      decoder=decoder,
      num_samples=100,
      items_to_descriptions=None) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:37,代碼來源:dataset_data_provider_test.py

示例2: _get_split

# 需要導入模塊: from tensorflow.contrib.slim.python.slim.data import dataset [as 別名]
# 或者: from tensorflow.contrib.slim.python.slim.data.dataset import Dataset [as 別名]
def _get_split(file_pattern, num_samples, num_views, image_size, vox_size):
  """Get dataset.Dataset for the given dataset file pattern and properties."""

  # A dictionary from TF-Example keys to tf.FixedLenFeature instance.
  keys_to_features = {
      'image': tf.FixedLenFeature(
          shape=[num_views, image_size, image_size, 3],
          dtype=tf.float32, default_value=None),
      'mask': tf.FixedLenFeature(
          shape=[num_views, image_size, image_size, 1],
          dtype=tf.float32, default_value=None),
      'vox': tf.FixedLenFeature(
          shape=[vox_size, vox_size, vox_size, 1],
          dtype=tf.float32, default_value=None),
  }

  items_to_handler = {
      'image': tfexample_decoder.Tensor(
          'image', shape=[num_views, image_size, image_size, 3]),
      'mask': tfexample_decoder.Tensor(
          'mask', shape=[num_views, image_size, image_size, 1]),
      'vox': tfexample_decoder.Tensor(
          'vox', shape=[vox_size, vox_size, vox_size, 1])
  }

  decoder = tfexample_decoder.TFExampleDecoder(
      keys_to_features, items_to_handler)

  return dataset.Dataset(
      data_sources=file_pattern,
      reader=tf.TFRecordReader,
      decoder=decoder,
      num_samples=num_samples,
      items_to_descriptions=_ITEMS_TO_DESCRIPTIONS) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:36,代碼來源:input_generator.py

示例3: get_split

# 需要導入模塊: from tensorflow.contrib.slim.python.slim.data import dataset [as 別名]
# 或者: from tensorflow.contrib.slim.python.slim.data.dataset import Dataset [as 別名]
def get_split(split_name, dataset_dir=None):
  """Gets a dataset tuple with instructions for reading cifar100.

  Args:
    split_name: A train/test split name.
    dataset_dir: The base directory of the dataset sources.

  Returns:
    A `Dataset` namedtuple. Image tensors are integers in [0, 255].

  Raises:
    ValueError: if `split_name` is not a valid train/test split.
  """
  if split_name not in _SPLITS_TO_SIZES:
    raise ValueError('split name %s was not recognized.' % split_name)

  file_pattern = os.path.join(dataset_dir, _FILE_PATTERN % split_name)

  keys_to_features = {
      'image/encoded': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/format': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/class/fine_label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
      'image/class/coarse_label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(shape=[32, 32, 3]),
      'fine_label': tfexample_decoder.Tensor('image/class/fine_label'),
      'coarse_label': tfexample_decoder.Tensor('image/class/coarse_label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(
      keys_to_features, items_to_handlers)

  return dataset.Dataset(
      data_sources=file_pattern,
      reader=tf.TFRecordReader,
      decoder=decoder,
      num_samples=_SPLITS_TO_SIZES[split_name],
      num_classes=_NUM_CLASSES,
      items_to_descriptions=_ITEMS_TO_DESCRIPTIONS) 
開發者ID:google,項目名稱:mentornet,代碼行數:45,代碼來源:cifar100_dataset.py

示例4: get_split

# 需要導入模塊: from tensorflow.contrib.slim.python.slim.data import dataset [as 別名]
# 或者: from tensorflow.contrib.slim.python.slim.data.dataset import Dataset [as 別名]
def get_split(split_name, dataset_dir=None):
  """Gets a dataset tuple with instructions for reading cifar10.

  Args:
    split_name: A train/test split name.
    dataset_dir: The base directory of the dataset sources.

  Returns:
    A `Dataset` namedtuple. Image tensors are integers in [0, 255].

  Raises:
    ValueError: if `split_name` is not a valid train/test split.
  """
  if split_name not in _SPLITS_TO_SIZES:
    raise ValueError('split name %s was not recognized.' % split_name)

  if dataset_dir is None:
    dataset_dir = _DATASET_DIR

  file_pattern = os.path.join(dataset_dir, _FILE_PATTERN % split_name)

  keys_to_features = {
      'image/encoded': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/format': tf.FixedLenFeature((), tf.string, default_value=''),
      'image/class/label': tf.FixedLenFeature(
          [1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)),
  }

  items_to_handlers = {
      'image': tfexample_decoder.Image(shape=[32, 32, 3]),
      'label': tfexample_decoder.Tensor('image/class/label'),
  }

  decoder = tfexample_decoder.TFExampleDecoder(
      keys_to_features, items_to_handlers)

  return dataset.Dataset(
      data_sources=file_pattern,
      reader=tf.TFRecordReader,
      decoder=decoder,
      num_samples=_SPLITS_TO_SIZES[split_name],
      num_classes=_NUM_CLASSES,
      items_to_descriptions=_ITEMS_TO_DESCRIPTIONS) 
開發者ID:google,項目名稱:mentornet,代碼行數:45,代碼來源:cifar10_dataset.py


注:本文中的tensorflow.contrib.slim.python.slim.data.dataset.Dataset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。