def __init__(self, filenames):
    """Create a `LMDBDataset`.

    `LMDBDataset` allows a user to read data from a mdb file as
    (key value) pairs sequentially.
    For example:
    ```python
    tf.compat.v1.enable_eager_execution()

    dataset = tf.contrib.lmdb.LMDBDataset("/foo/bar.mdb")

    # Prints the (key, value) pairs inside a lmdb file.
    for key, value in dataset:
      print(key, value)
    ```
    Args:
      filenames: A `tf.string` tensor containing one or more filenames.
    """
    self._filenames = ops.convert_to_tensor(
        filenames, dtype=dtypes.string, name="filenames")
    if compat.forward_compatible(2019, 8, 3):
      variant_tensor = gen_experimental_dataset_ops.lmdb_dataset(
          self._filenames, **self._flat_structure)
    else:
      variant_tensor = gen_experimental_dataset_ops.experimental_lmdb_dataset(
          self._filenames, **self._flat_structure)
    super(LMDBDataset, self).__init__(variant_tensor)
Example #2
0
    def __init__(self, filenames):
        """Create a `LMDBDataset`.

    `LMDBDataset` allows a user to read data from a mdb file as
    (key value) pairs sequentially.
    For example:
    ```python
    dataset = tf.contrib.lmdb.LMDBDataset("/foo/bar.mdb")
    iterator = dataset.make_one_shot_iterator()
    next_element = iterator.get_next()
    # Prints the (key, value) pairs inside a lmdb file.
    while True:
      try:
        print(sess.run(next_element))
      except tf.errors.OutOfRangeError:
        break
    ```
    Args:
      filenames: A `tf.string` tensor containing one or more filenames.
    """
        self._filenames = ops.convert_to_tensor(filenames,
                                                dtype=dtypes.string,
                                                name="filenames")
        variant_tensor = gen_experimental_dataset_ops.experimental_lmdb_dataset(
            self._filenames, **dataset_ops.flat_structure(self))
        super(LMDBDataset, self).__init__(variant_tensor)
Example #3
0
  def __init__(self, filenames):
    """Create a `LMDBDataset`.

    `LMDBDataset` allows a user to read data from a mdb file as
    (key value) pairs sequentially.
    For example:
    ```python
    tf.enable_eager_execution()

    dataset = tf.contrib.lmdb.LMDBDataset("/foo/bar.mdb")

    # Prints the (key, value) pairs inside a lmdb file.
    for key, value in dataset:
      print(key, value)
    ```
    Args:
      filenames: A `tf.string` tensor containing one or more filenames.
    """
    self._filenames = ops.convert_to_tensor(
        filenames, dtype=dtypes.string, name="filenames")
    variant_tensor = gen_experimental_dataset_ops.experimental_lmdb_dataset(
        self._filenames, **dataset_ops.flat_structure(self))
    super(LMDBDataset, self).__init__(variant_tensor)
Example #4
0
 def _as_variant_tensor(self):
     return gen_experimental_dataset_ops.experimental_lmdb_dataset(
         self._filenames,
         output_types=nest.flatten(self.output_types),
         output_shapes=nest.flatten(self.output_shapes))
Example #5
0
 def _as_variant_tensor(self):
     return gen_experimental_dataset_ops.experimental_lmdb_dataset(
         self._filenames, **dataset_ops.flat_structure(self))
Example #6
0
 def _as_variant_tensor(self):
   return gen_experimental_dataset_ops.experimental_lmdb_dataset(
       self._filenames,
       output_types=nest.flatten(self.output_types),
       output_shapes=nest.flatten(self.output_shapes))