LeonJWH opened a new issue #7664: index out of bound error when update eval 
metric
URL: https://github.com/apache/incubator-mxnet/issues/7664
 
 
   Hi ,I am training a binary classification model with my own dataset. I use 
**mx.image.ImageIter** API to load raw images according to the **.lst** file 
generated myself(with using **img2rec.py**).
   I set the data iter as below,
   ```
   train_iter = mx.image.ImageIter(
           batch_size   = batch_size,
           data_shape   = data_shape,
           path_imglist = '/database/liveness/data_prepare/liveness_train.lst',
           path_root    = '/',
           data_name    = 'data',
           label_name   = 'softmax_label',
           mean         = np.array([123.68, 116.78, 103.94]),
           resize       = 224,
           rand_mirror  = True,
           shuffle      = False,
           inter_method = 1)
   ```.
   And my **.lst** file is
   ```
   16      1.0     
/database/liveness/lf_face/real/5905c125337f3131b4f0856a_image_0.jpg
   17      1.0     
/database/liveness/lf_face/real/58dd0a71337f311c56026c9e_image_0.jpg
   18      1.0     
/database/liveness/lf_face/real/58fb11d6de6c741b3501fd52_image_0.jpg
   19      1.0     
/database/liveness/lf_face/real/59060ef0337f317a0f74a42e_image_0.jpg
   ```.
   Then i start training, the first epoch went well, but a error was reported 
at the second epoch(epoch 1) as follow,
   ```
   Traceback (most recent call last):
     File "train.py", line 113, in <module>
       mod.update_metric(metric, batch.label)
     File "/dlproject/incubator-mxnet/python/mxnet/module/module.py", line 735, 
in update_metric
       self._exec_group.update_metric(eval_metric, labels)
     File "/dlproject/incubator-mxnet/python/mxnet/module/executor_group.py", 
line 582, in update_metric
       eval_metric.update_dict(labels_, preds)
     File "/dlproject/incubator-mxnet/python/mxnet/metric.py", line 280, in 
update_dict
       metric.update_dict(labels, preds)
     File "/dlproject/incubator-mxnet/python/mxnet/metric.py", line 108, in 
update_dict
       self.update(label, pred)
     File "/dlproject/incubator-mxnet/python/mxnet/metric.py", line 916, in 
update
       prob = pred[numpy.arange(label.shape[0]), numpy.int64(label)]
   IndexError: index -275 is out of bounds for axis 1 with size 2
   ```
   I set the eval metric in my training script with two parts:
   ```
   eval_metric = mx.metric.CompositeEvalMetric()
   eval_metric.add(mx.metric.CrossEntropy())
   eval_metric.add(mx.metric.Accuracy())
   ```,
   so what is wrong in my usage?
   Thx for your answer!
   
 
----------------------------------------------------------------
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