MXNet Text Classification demo error

#1

Hi,

I’m using the convolution-based text classif demo on another subset of AMZN reviews https://github.com/ThomasDelteil/TextClassificationCNNs_MXNet/blob/master/Crepe-Gluon.ipynb
I have the following error.
I have similar error when I’m only looking at DataLoader content. There seems to be something wrong in the input pipeline. Can someone have a look and tell me if the demo code is still valid?
I’m for example suprised to see some np code in the encode transform
Cheers

Process Process-24:
Traceback (most recent call last):
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
Process Process-23:
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 184, in worker_loop
batch = batchify_fn([dataset[i] for i in samples])
Traceback (most recent call last):
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in default_mp_batchify_fn
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 151, in default_mp_batchify_fn
ctx=context.Context(‘cpu_shared’, 0))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 184, in worker_loop
batch = batchify_fn([dataset[i] for i in samples])
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/utils.py”, line 146, in array
return _array(source_array, ctx=ctx, dtype=dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in default_mp_batchify_fn
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 2434, in array
arr = empty(source_array.shape, ctx, dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 3823, in empty
return NDArray(handle=_new_alloc_handle(shape, ctx, False, dtype))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 138, in _new_alloc_handle
ctypes.c_int(int(DTYPE_NP_TO_MX[np.dtype(dtype).type])),
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 151, in default_mp_batchify_fn
ctx=context.Context(‘cpu_shared’, 0))
KeyError: <class 'numpy.str
’>
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/utils.py”, line 146, in array
return _array(source_array, ctx=ctx, dtype=dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 2434, in array
arr = empty(source_array.shape, ctx, dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 3823, in empty
return NDArray(handle=_new_alloc_handle(shape, ctx, False, dtype))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 138, in _new_alloc_handle
ctypes.c_int(int(DTYPE_NP_TO_MX[np.dtype(dtype).type])),
KeyError: <class 'numpy.str
’>
Process Process-22:
Traceback (most recent call last):
Process Process-21:
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
Traceback (most recent call last):
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 184, in worker_loop
batch = batchify_fn([dataset[i] for i in samples])
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in default_mp_batchify_fn
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 151, in default_mp_batchify_fn
ctx=context.Context(‘cpu_shared’, 0))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 184, in worker_loop
batch = batchify_fn([dataset[i] for i in samples])
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in default_mp_batchify_fn
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 151, in default_mp_batchify_fn
ctx=context.Context(‘cpu_shared’, 0))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/utils.py”, line 146, in array
return _array(source_array, ctx=ctx, dtype=dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/utils.py”, line 146, in array
return _array(source_array, ctx=ctx, dtype=dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 2434, in array
arr = empty(source_array.shape, ctx, dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 2434, in array
arr = empty(source_array.shape, ctx, dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 3823, in empty
return NDArray(handle=_new_alloc_handle(shape, ctx, False, dtype))
Process Process-25:
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 3823, in empty
return NDArray(handle=_new_alloc_handle(shape, ctx, False, dtype))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 138, in _new_alloc_handle
ctypes.c_int(int(_DTYPE_NP_TO_MX[np.dtype(dtype).type])),
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 138, in new_alloc_handle
ctypes.c_int(int(DTYPE_NP_TO_MX[np.dtype(dtype).type])),
KeyError: <class 'numpy.str
’>
KeyError: <class 'numpy.str
’>
Traceback (most recent call last):
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 258, in _bootstrap
self.run()
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/multiprocessing/process.py”, line 93, in run
self._target(*self._args, **self._kwargs)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 184, in worker_loop
batch = batchify_fn([dataset[i] for i in samples])
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in default_mp_batchify_fn
return [default_mp_batchify_fn(i) for i in data]
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 147, in
return [default_mp_batchify_fn(i) for i in data]

File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/data/dataloader.py”, line 151, in default_mp_batchify_fn
ctx=context.Context(‘cpu_shared’, 0))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/utils.py”, line 146, in array
return _array(source_array, ctx=ctx, dtype=dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 2434, in array
arr = empty(source_array.shape, ctx, dtype)
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 3823, in empty
return NDArray(handle=_new_alloc_handle(shape, ctx, False, dtype))
File “/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py”, line 138, in _new_alloc_handle
ctypes.c_int(int(DTYPE_NP_TO_MX[np.dtype(dtype).type])),
KeyError: <class 'numpy.str
’>

#2

my mistake, I was not label-encoding the target…:grinning:

1 Like