2017-06-15 51 views
1

lro_labels和數據的Mxnet綁定錯誤我使用mxnet通過微調resnet50做圖像的迴歸(4個標籤)。用於圖像迴歸

  1. 我改變SoftmaxOutput與LinearRegressionOutput在符號
  2. 我改變圖像標籤爲多個
  3. 我用來代替訓練ACC度量= mx.metric.MSE()。

所以符號就像是在最後一層。

{ 
"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) 數據:(36,3,227,227) 回溯(最近通話最後一個): 文件 「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,以結合 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,在初始化 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/p ython2.7/DIST-包/ mxnet-0.10.1-py2.7.egg/mxnet /模塊/ executor_group.py 「線路582,在_bind_ith_exec shared_buffer將= shared_data_arrays,** input_shapes) 文件」 的/ usr /本地/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/symbol.py「,第1375行,在simple_bind中 raise RuntimeError('simple_bind failed') RuntimeError:simple_bind失敗

似乎在

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,不存在這樣的問題。 發生了什麼?

回答

1

我有兩個錯誤的部分:

  • num_class必須是1,而不是分類標籤
  • lro_label:(36)應lro_label:(36,1,)