I use mxnet to do image regression(4 labels) by fine-tuning resnet50.
- I changed SoftmaxOutput with LinearRegressionOutput in symbol
- I changed image label into a number
- I used metric=mx.metric.MSE() instead of training acc.
So the symbol is like in the last layer.
{
"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]]
}
],
But when I run the code I have an error like simple_bind error.
simple_bind error. Arguments: lro_label: (36,) data: (36, 3, 227, 227) Traceback (most recent call last): File "finetune.py", line 59, in for_training=True) File "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/module/module.py", line 388, in bind state_names=self._state_names) File "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/module/executor_group.py", line 310, in bind_exec shared_group)) File "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-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
It seems the error happened in
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)
Input and output is not same, but when I use softmax, there is no such problem. What happened?