EsraaRagaa opened a new issue #7420: How to pass CSVIter (images flatten in 
.csv file) to MXNet ?
URL: https://github.com/apache/incubator-mxnet/issues/7420
 
 
   # Hello, 
   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:
   label, pixel1, pixel2, ..., pixel400
   0,...
   1,...
   and my labels are 0 or 1, 
   # this is the code I used:
   ---------------------
   train_data = pd.read_csv("training_set_flatten_rows_mxnet.csv")
   keys = ['pixel.'+str(i) for i in range(1,402)]
   X_train = train_data[keys[1:]].get_values()
   X_train = X_train.reshape((2779,1,20,20))
   Y_train = train_data['pixel.1'].get_values().reshape((2779,1))
   
   validate_data = pd.read_csv("validation_set_flatten_rows_mxnet.csv")
   keys = ['pixel.'+str(i) for i in range(1,402)]
   X_validate = validate_data[keys[1:]].get_values()
   X_validate = X_validate.reshape((692,1,20,20))
   Y_validate = validate_data['pixel.1'].get_values().reshape((692,1))
   
   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 "<ipython-input-173-bf3d68caa271>", line 7, in <module>
       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 388, in bind
       state_names=self._state_names)
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\executor_group.py",
 line 214, in __init__
       self.bind_exec(data_shapes, label_shapes, shared_group)
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\executor_group.py",
 line 310, in bind_exec
       shared_group))
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\executor_group.py",
 line 582, in _bind_ith_exec
       shared_buffer=shared_data_arrays, **input_shapes)
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\symbol.py",
 line 1375, in simple_bind
       raise RuntimeError('simple_bind failed')
   
   RuntimeError: simple_bind failed
   
   # If I comment this line in the model.fit ::
    #batch_end_callback = mx.callback.Speedometer(batch_size, 100),
   
   # I get error: 
   WARNING:root:Already bound, ignoring bind()
   Traceback (most recent call last):
   
     File "<ipython-input-176-a2b29eed591d>", line 7, in <module>
       num_epoch=10)
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\base_module.py",
 line 463, in fit
       allow_missing=allow_missing, force_init=force_init)
   
     File 
"C:\Users\...\Anaconda2\lib\site-packages\mxnet-0.10.1-py2.7.egg\mxnet\module\module.py",
 line 272, in init_params
       for name, arr in self._arg_params.items():
   
   AttributeError: 'NoneType' object has no attribute 'items'
   
   I guess the error is from the the data load and passing to mxnet. 
   I don't know what does this mean and what shall I do, help me, please.
   
   
   I am using win10, python2, mxnet 0.10, anaconda2
   Thanks in advance
   
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to