Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Using numpy.ndarray for Input Data #199

@II-Matto

Description

@II-Matto

After trying the MNIST mlp.py example, I wanted to use my own data to train an MLP. So I load input from *.txt files in python as numpy.ndarray, which are then taken as arguments of model.fit(). But I keep getting the following error:

Traceback (most recent call last):
File "test.py", line 36, in
model.fit(X=train_data, y=train_label, eval_data=(val_data, val_label))
File "/home/code/xxx/mxnet/mxnet_master/python/mxnet/model.py", line 675, in fit
logger=logger)
File "/home/code/xxx/mxnet/mxnet_master/python/mxnet/model.py", line 273, in _train_multi_device
label[islice].copyto(target)
File "/home/code/xxx/mxnet/mxnet_master/python/mxnet/ndarray.py", line 320, in copyto
return NDArray._copyto(self, out=other)
File "/home/code/xxx/mxnet/mxnet_master/python/mxnet/ndarray.py", line 640, in generic_ndarray_function
c_array(NDArrayHandle, [v.handle for v in mutate_vars])))
File "/home/code/xxx/mxnet/mxnet_master/python/mxnet/base.py", line 72, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [21:58:27] src/ndarray/ndarray.cc:158: Check failed: from.shape() == to->shape() operands shape mismatch

My data is represented as 1500-dim feature vectors. The shapes of my data array are:

train_data.shape = (1800, 1500)
train_label.shape = (1800, 1)
val_data.shape = (200, 1500)
val_label.shape = (200, 1)

The MLP has two output units for the last layer. And I have tried transposing the input data array, using 1500 units for fc1, and using 2-dim labels (for two output units). None of them helps.

So what is the correct way to use my own data? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions