2017-03-12 128 views
0

我一直在嘗試基於完全卷積神經網絡對此semantic segmentation code進行實驗。然而,運行此代碼生成造成類型錯誤的錯誤消息:索引必須是整數

fcn32model = fcn32_blank(image_size) 

我沒有更改任何代碼下面的錯誤消息,並且也很困惑是什麼導致這個錯誤。

Using Theano backend. 
Traceback (most recent call last): 
File "train.py", line 20, in <module> 
    fcn32model = fcn32_blank(image_size) 
File "/home/FCN/fcn16s/utils.py", line 78, in fcn32_blank 
(extra_margin/2, extra_margin/2)))) # INFO : cropping as deconv gained pixels 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/models.py", line 332, in add 
output_tensor = layer(self.outputs[0]) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 572, in __call__ 
self.add_inbound_node(inbound_layers, node_indices, tensor_indices) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 635, in add_inbound_node 
Node.create_node(self, inbound_layers, node_indices, tensor_indices) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 166, in create_node 
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/layers/convolutional.py", line 1817, in call 
self.cropping[1][0]:-self.cropping[1][1]] 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/var.py", line 540, in __getitem__ 
return theano.tensor.subtensor.advanced_subtensor(self, *args) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/gof/op.py", line 604, in __call__ 
node = self.make_node(*inputs, **kwargs) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2140, in make_node 
index = tuple(map(as_index_variable, index)) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2081, in as_index_variable 
return make_slice(idx) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/gof/op.py", line 604, in __call__ 
node = self.make_node(*inputs, **kwargs) 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/type_other.py", line 39, in make_node 
list(map(as_int_none_variable, inp)), 
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/type_other.py", line 20, in as_int_none_variable 
raise TypeError('index must be integers') 
TypeError: index must be integers 

回答

-1

它強制轉換爲int

(int(extra_margin/2), int(extra_margin/2)) 
相關問題