mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Data provided by data_shapes don't match names specified by data_names

Open EsraaRagaa opened this issue 9 years ago • 5 comments

I am trying to train my data with mxnet, the data are 20x20 images I put my data in a csv files in the form: image1>>>px1 px2 ,,,,,px400 ............... .............. and labels 1 0 . . and my labels are 0 or 1,

this is the code I used:

batch_size = 2 train_iterator = mx.io.NDArrayIter(X_train, Y_train, batch_size=batch_size) validate_iterator = mx.io.NDArrayIter(X_validate, Y_validate, batch_size=batch_size)

##first convelutional layer conv1 = mx.sym.Convolution(data=data, kernel=(3,3), num_filter=6) relu1 = mx.sym.Activation(data=conv1, act_type="relu") pool1 = mx.sym.Pooling(data=relu1, pool_type="max", kernel=(2,2), stride=(2,2))

##second convelutional layer conv2 = mx.sym.Convolution(data=pool1, kernel=(6,6), num_filter=12) relu2 = mx.sym.Activation(data=conv2, act_type="relu") pool2 = mx.sym.Pooling(data=relu2, pool_type="max", kernel=(2,2), stride=(2,2))

##first fully connected layer flatten = mx.sym.flatten(data=pool2) fc1 = mx.symbol.FullyConnected(data=flatten, num_hidden=12 )

##softmax loss lenet = mx.sym.SoftmaxOutput(data=fc1, name='softmax')

##create a trainable module on CPU 0 lenet_model = mx.mod.Module(symbol=lenet, context=mx.cpu()) device = mx.cpu()

##train using parameters

''' model = mx.model.FeedForward.create(lenet_model, X = X_train, y = Y_train, ctx = device, num_epoch = 10) ''' lenet_model.fit(train_iterator, eval_data=validate_iterator, optimizer='sgd', optimizer_params={'learning_rate':0.1}, eval_metric='acc', batch_end_callback = mx.callback.Speedometer(batch_size, 100), num_epoch=10)

the error is:

Traceback (most recent call last):

File "", line 7, in num_epoch=10)

File "C:\Users...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\base_module.py", line 459, in fit for_training=True, force_rebind=force_rebind)

File "C:\Users...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\module.py", line 372, in bind self.data_names, self.label_names, data_shapes, label_shapes)

File "C:\Users...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\base_module.py", line 70, in _parse_data_desc _check_names_match(data_names, data_shapes, 'data', True)

File "C:\Users...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\base_module.py", line 62, in _check_names_match raise ValueError(msg)

ValueError: Data provided by data_shapes don't match names specified by data_names ([DataDesc[_0_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_1_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_2_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_3_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_4_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_5_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_6_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_7_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_8_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_9_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_10_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_11_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_12_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_13_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_14_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_15_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_16_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_17_data,(2,),<type 'numpy.float32'>,NCHW], ... ... ... ... , DataDesc[_2773_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_2774_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_2775_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_2776_data,(2,),<type 'numpy.float32'>,NCHW], DataDesc[_2777_data,(2,),<type 'numpy.float32'>,NCHW]] vs. ['data'])

What should the data look like, what is wrong in the code, please?

I am using win10, python2, mxnet 0.10, anaconda2 Thanks in advance

EsraaRagaa avatar Aug 11 '17 02:08 EsraaRagaa

I met this problem, and your code is ok, I guess is the bug, in module/base_module.py _parase_data_desc

AihahaFox avatar Aug 11 '17 08:08 AihahaFox

This issue is closed due to lack of activity in the last 90 days. Feel free to ping me to reopen if this is still an active issue. Thanks! Also, do please check out our forum (and Chinese version) for general "how-to" questions.

szha avatar Nov 10 '17 12:11 szha

There are close to 5 issues which have been opened by different users for a similar problem and in every thread I see that the contributor closes the issue because of "lack of activity". I don't know why are you not solving the issue in the first place. ? Sorry for being rude but this is the harsh reality.

SrivastavaKshitij avatar Nov 28 '17 19:11 SrivastavaKshitij

@SrivastavaKshitij I apologize if the auto-message upsets you. The "lack of activity" in the automatic message merely refers to this issue being inactive in terms of not having new comments, nor an issue-label that's being tracked.

On this specific issue, this (i.e. shape mismatch) is the most common user error in symbolic programming, which is part of the reason why contributors are less inclined to help. So please do realize that asking for help on this issue is in most cases equivalent of asking others to debug your program. If you believe this is due to a bug in the code, please consider providing a minimum reproducible sample code, in which the API is used as intended but the result isn't. Thank you for your cooperation.

szha avatar Nov 28 '17 23:11 szha

Also, if you're new to mxnet, we have a new high-level interface called "Gluon" that's a lot easier to use and faster to develop than the previous symbolic interface. We have a set of awesome tutorials to showcase its usage that you can checkout at http://gluon.mxnet.io/

szha avatar Nov 28 '17 23:11 szha