MXNet Forum

Feeding sparse data to DataLoader


Is there a way to feed sparse data to a gluon DataLoader?
In a public gluon SageMaker example, this is done via creating an ad-hoc class:

class SparseMatrixDataset(
    def __init__(self, data, label):
        assert data.shape[0] == len(label) = data
        self.label = label
        if isinstance(label, ndarray.NDArray) and len(label.shape) == 1:
            self._label = label.asnumpy()
            self._label = label       
    def __getitem__(self, idx):
        return[idx, 0],[idx, 1], self.label[idx]
    def __len__(self):

Is there a simpler way?


Take a look into this example. They use, but there is a comment that it is an experimental feature and should be used with care.