GeezerVison is showing github.com — regression metrics report error · Issue #1239 · apache/mxnet
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.
regression metrics report error #1239Descriptionhi,all, i have a regression task , and my data save in disk by numpy.memmap. I use below function do a simple regression test under mxnet.
data_set = np.memmap(input_data,dtype='float32',mode='r',shape=(100000,18))
label_set = np.memmap(input_label,dtype='int',mode='r',shape=(100000,))
train_label = label_set[:80000,]
eval_label = label_set[80000:,]
train_data = mx.io.NDArrayIter(data = data_set[:80000,:], label= {'lr_label':train_label},batch_size = 1000)
eval_data = mx.io.NDArrayIter(data = data_set[80000:,:], label= {'lr_label': eval_label},batch_size = 1000)
data = mx.symbol.Variable('data')
fc1 = mx.symbol.FullyConnected(data, name='fc1', num_hidden=16)
act1 = mx.symbol.Activation(fc1, name='relu1', act_type='relu')
fc2 = mx.symbol.FullyConnected(act1, name='fc2', num_hidden=8)
act2 = mx.symbol.Activation(fc2, name='relu2', act_type='relu')
fc3 = mx.symbol.FullyConnected(act2,name='fc3',num_hidden=1)
lr = mx.symbol.LogisticRegressionOut(fc3, name='lr')
model = mx.model.FeedForward(symbol = lr,num_epoch=20,learning_rate=0.1,wd=0.1)
model.fit(X=train_data,eval_data=eval_data,eval_metric=mx.metric.RMSE())
run this script, report error
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/metric.py", line 82, in update
assert label.shape == pred.shape
before start, i print eval label shape is (20000,) and eval data also is (20000,18), but test log shows label shape unequal pred shape.....
however,if i use default parameter, for example,model.fit(X=train_data,eval_data=eval_data), model fit work well, but no any messages be print out, i con't confirm which is corrent or not, i think it should print somthing to tell me model acc or other usefull messages .....
anybody knows what's the reason of that? thanks Activitypiiswrong commented on Jan 11, 2016 First, you need to set logging level to DEBUG with logging.basicConfig(level=logging.DEBUG)
Second could you print the label and pred shapes when assert fails? leoli2012 commented on Jan 12, 2016 @piiswrong hi ,i opened set logging debug level ,print out label and pred shapes.
INFO:root:Start training with [cpu(0)]
label shape: (1000L,)
pred shape: (1000L, 1L)
Traceback (most recent call last):
File "aes.py", line 163, in
handle(data)
File "aes.py", line 147, in handle
dl_lr_model(sample_data_npy,sample_label_npy)
File "aes.py", line 133, in dl_lr_model
model.fit(X=train_data,eval_data=eval_data,eval_metric=mx.metric.RMSE())
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/model.py", line 656, in fit
logger=logger, work_load_list=work_load_list, monitor=monitor)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/model.py", line 241, in _train_multi_device
eval_metric.update(data_batch.label, executor_manager.cpu_output_arrays)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/metric.py", line 86, in update
assert label.shape == pred.shape
message shows label shape is (1000,),but pred label is (1000,1). by the way , does shape (1000,) is not the alias of (1000,1)?
then ,i modified the label define code
label_set = np.memmap(input_label,dtype='int',mode='r',shape=(100000,1)), ##before is (100000,)
i print out my label shape, is (100000,1), then i run again, report below error messages
INFO:root:Start training with [cpu(0)]
[09:41:26] ./dmlc-core/include/dmlc/logging.h:208: [09:41:26] src/ndarray/ndarray.cc:159: Check failed: from.shape() == to->shape() operands shape mismatch
Traceback (most recent call last):
File "aes.py", line 163, in
handle(data)
File "aes.py", line 147, in handle
dl_lr_model(sample_data_npy,sample_label_npy)
File "aes.py", line 133, in dl_lr_model
model.fit(X=train_data,eval_data=eval_data,eval_metric=mx.metric.RMSE())
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/model.py", line 656, in fit
logger=logger, work_load_list=work_load_list, monitor=monitor)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/model.py", line 218, in _train_multi_device
executor_manager.load_data_batch(data_batch)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/executor.py", line 425, in load_data_batch
_load_label(data_batch, self.label_arrays)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/executor.py", line 309, in _load_label
_load_general(batch.label, targets)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/executor.py", line 301, in _load_general
d_src[slice_idx].copyto(d_dst)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/ndarray.py", line 361, in copyto
return NDArray._copyto(self, out=other)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/ndarray.py", line 654, in unary_ndarray_function
c_array(NDArrayHandle, (out.handle,))))
File "/usr/local/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/base.py", line 76, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [09:41:26] src/ndarray/ndarray.cc:159: Check failed: from.shape() == to->shape() operands shape mismatch
this issue seems like describe in :#1163 piiswrong commented on Jan 12, 2016 This can be fixed with adding label=label.asnumpy().squeeze() and similar for pred before assert. in metric. Would you like to contributed a PR?
BTW, could you print the shape at here?
File "/net/noble/vol1/home/jmschr/anaconda/lib/python2.7/site-packages/mxnet-0.5.0-py2.7.egg/mxnet/executor.py", line 293, in _load_general
d_src[slice_idx].copyto(d_dst) jmschrei commented on Jan 12, 2016 This should be fixed in #1167 as soon as I get lint working. leoli2012 commented on Jan 12, 2016 @piiswrong , sorry for delayed reply~i think my label shape should be(10000,1) format,not (10000,), they represent a matrix and a vector,i misundstand numpy shape format before, however, if i use (xx,1) label format, script will fail for "Check failed: from.shape() == to->shape() operands shape mismatch" reason
BTW, i also use label format(10000,), depend on your adivces , i added "label=label.asnumpy().squeeze()" before assert and del asunmpy method called later part in metric, and it's ok now. jmschrei commented on Jan 14, 2016 This should be fixed on master branch now. Let me know if it isn't.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|