You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/01/25 06:15:11 UTC
[GitHub] Rikorose commented on issue #9531: KeyError: in mx.nd.array.empty()
Rikorose commented on issue #9531: KeyError: <class 'numpy.object_'> in mx.nd.array.empty()
URL: https://github.com/apache/incubator-mxnet/issues/9531#issuecomment-360371878
As I said, this error didn't occur consistently. Now I cannot reproduce it anymore. Anyway here is my code using numpy array since I do not know a native approach with `mx.ndarray`:
```py
class NumpyArrayRecordDataset(mx.gluon.data.RecordFileDataset):
def __init__(self, filename):
super().__init__(filename)
def __getitem__(self, idx):
item = super().__getitem__(idx)
header, np_bytes = mx.recordio.unpack(item)
label = header.label
features = np.expand_dims(np.load(io.BytesIO(np_bytes)), axis=0)
return label, features
def data_loader(record_file, batch_size=1, shuffle=True, last_batch='rollover'):
dataset = NumpyArrayRecordDataset(record_file)
loader = mx.gluon.data.DataLoader(
dataset=dataset,
batch_size=batch_size,
shuffle=shuffle,
last_batch=last_batch)
return loader
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services