KPLRecordReader

class dragon.vm.dali.ops.KPLRecordReader(
  path,
  features,
  pipeline,
  shard_id=0,
  num_shards=1,
  shuffle_after_epoch=False,
  shuffle_chunks=0
)[source]

Read examples from the KPLRecord.

Examples:

class MyPipeline(dali.Pipeline):
    def __init__():
        super(MyPipeline, self).__init__()
        # Assume the we have the following data:
        # /data/root.data
        # /data/root.index
        # /data/root.meta
        self.reader = dali.ops.KPLRecordReader(
            path='/data'
            features=('image', 'label'),
            pipeline=self,
            # Shuffle globally within specified number of chunks
            # once an epoch is finished
            shuffle_after_epoch=True,
            # Set **0** to split each example as a chunk
            shuffle_chunks=0,
        )

    def iter_step(self):
        self.reader.feed_inputs()

    def define_graph(self):
        inputs = self.reader()

__init__

KPLRecordReader.__init__(
  path,
  features,
  pipeline,
  shard_id=0,
  num_shards=1,
  shuffle_after_epoch=False,
  shuffle_chunks=0
)[source]

Create a KPLRecordReader.

Parameters:
  • path (str) – The folder of record files.
  • shard_id (int, optional, default=0) – The index of specific shard.
  • num_shards (int, optional, default=1) – The total number of shards.
  • shuffle_after_epoch (bool, optional, default=False) – True to shuffle examples once an epoch is finished.
  • shuffle_chunks (int, optional, default=0) – The number of chunks to shuffle.

Methods

example_to_data

KPLRecordReader.example_to_data(example)[source]

Define the translation from example to array data.

Override this method to implement the translation.

feed_inputs

KPLRecordReader.feed_inputs()[source]

Feed the data to edge references.

Call this method in the Pipeline.iter_setup(...).

__call__

KPLRecordReader.__call__(
  *args,
  **kwargs
)[source]

Create the edge references for features.

Call this method in the Pipeline.define_graph(...).

Returns:
Dict[str, _EdgeReference] – The feature reference dict.