contrib.io

Contrib data iterators for common data formats.

Classes

DataLoaderIter(loader[, data_name, …])

Returns an iterator for mx.gluon.data.Dataloader so gluon dataloader can be used in symbolic module.

class DataLoaderIter(loader, data_name='data', label_name='softmax_label', dtype='float32')[source]

Bases: mxnet.io.io.DataIter

Returns an iterator for mx.gluon.data.Dataloader so gluon dataloader can be used in symbolic module.

Parameters
  • loader (mxnet.gluon.data.Dataloader) – Gluon dataloader instance

  • data_name (str, optional) – The data name.

  • label_name (str, optional) – The label name.

  • dtype (str, optional) – The dtype specifier, can be float32 or float16

Methods

getdata()

Get data of current batch.

getindex()

Get index of the current batch.

getlabel()

Get label of the current batch.

getpad()

Get the number of padding examples in the current batch.

iter_next()

Move to the next batch.

reset()

Reset the iterator to the begin of the data.

Examples

>>> import mxnet as mx
>>> from mxnet.gluon.data.vision import MNIST
>>> from mxnet.gluon.data import DataLoader
>>> train_dataset = MNIST(train=True)
>>> train_data = mx.gluon.data.DataLoader(train_dataset, 32, shuffle=True, num_workers=4)
>>> dataiter = mx.io.DataloaderIter(train_data)
>>> for batch in dataiter:
...     batch.data[0].shape
...
(32L, 28L, 28L, 1L)
getdata()[source]

Get data of current batch.

Returns

The data of the current batch.

Return type

list of NDArray

getindex()[source]

Get index of the current batch.

Returns

index – The indices of examples in the current batch.

Return type

numpy.array

getlabel()[source]

Get label of the current batch.

Returns

The label of the current batch.

Return type

list of NDArray

getpad()[source]

Get the number of padding examples in the current batch.

Returns

Number of padding examples in the current batch.

Return type

int

iter_next()[source]

Move to the next batch.

Returns

Whether the move is successful.

Return type

boolean

reset()[source]

Reset the iterator to the begin of the data.