Mxnet绑定lro_labels的错误和图像回归的数据

问题描述 投票:1回答:1

我通过微调resnet50使用mxnet进行图像回归(4个标签)。

  1. 我用符号中的LinearRegressionOutput更改了SoftmaxOutput
  2. 我将图片标签更改为数字
  3. 我使用metric = mx.metric.MSE()而不是acc acc。

所以符号就像在最后一层。

{
"op": "FullyConnected",
"name": "fc",
"attr": {"num_hidden": "4"},
"inputs": [[430, 0, 0], [431, 0, 0], [432, 0, 0]]
},
{
"op": "null",
"name": "lro_label",
"inputs": []
},
{
"op": "LinearRegressionOutput",
"name": "lro",
"inputs": [[433, 0, 0], [434, 0, 0]]
}
],

但是当我运行代码时,我遇到了像simple_bind错误这样的错误。

simple_bind错误。参数:lro_label:(36,)data:(36,3,227,227)Traceback(最近一次调用last):文件“finetune.py”,第59行,for_training = True)文件“/ usr / local / lib /python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/module/module.py“,第388行,在bind state_names = self._state_names中)文件”/ usr / local / lib / python2.7 / dist-packages / mxnet-0.10.1-py2.7.egg / mxnet / module / executor_group.py“,第214行,在init self.bind_exec(data_shapes,label_shapes,shared_group)文件”/ usr / local /lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/module/executor_group.py“,第310行,在bind_exec shared_group中))文件”/ usr / local / lib / python2 .7 / dist-packages / mxnet-0.10.1-py2.7.egg / mxnet / module / executor_group.py“,第582行,_bind_ith_exec shared_buffer = shared_data_arrays,** input_shapes)文件”/ usr / local / lib / python2.7 / dist-packages / mxnet-0.10.1-py2.7.egg / mxnet / symbol.py“,第1375行,在simple_bind中引发RuntimeError('simple_bind failed')RuntimeError:simple_bind failed

似乎错误发生在

mod = mx.module.Module( symbol=new_sym, context=ctx, data_names=('data',), label_names=('lro_label',)) 
mod.bind(data_shapes=[('data', (batch_size, 3, 227, 227))], label_shapes=[('lro_label', (batch_size,))], for_training=True)

输入和输出不一样,但是当我使用softmax时,没有这样的问题。发生了什么?

regression bind conv-neural-network mxnet resnet
1个回答
1
投票

我有两个错误的部分:

  • num_class需要为1而不是分类标签
  • lro_label:(36,)应该是lro_label:(36,1,)
© www.soinside.com 2019 - 2024. All rights reserved.