我目前收到一条错误消息,表示我正在迭代的列表的索引范围之外,但根本不是这种情况。 当我调用conv1d(输入)时,似乎出现错误,但这些调用存储在列表中,以避免编写多行代码,即复制粘贴。
以下是代码:
list_of_input = [Input(shape = (window_height,total_frames_with_deltas,3)) for i in range(splits)]
list_of_convolution = [(Conv1D(filters = J, kernel_size = 8)) for i in range(45)]
conv_output = []
for inputs in list_of_input:
s = Lambda(slice)(inputs)
for index in xrange(len(list_of_convolution)):
print len(s)
print type(s)
print len(list_of_convolution)
print type(list_of_convolution)
print index
print "At index"
print s[index]
print "con"
print list_of_convolution[index]
print "Some"
output = list_of_convolution[index](s[index])
print "utu"
conv_output.append(output)
print len(conv_output)
raw_input("Soes")
这是我收到的输出错误信息:
45
<type 'list'>
45
<type 'list'>
0
At index
Tensor("lambda_1/strided_slice:0", shape=(?, 8, 3), dtype=float32)
con
<keras.layers.convolutional.Conv1D object at 0x7fef61fa2a90>
Some
utu
1
Soes
45
<type 'list'>
45
<type 'list'>
1
At index
Tensor("lambda_1/strided_slice_1:0", shape=(?, 8, 3), dtype=float32)
con
<keras.layers.convolutional.Conv1D object at 0x7fef61fa2d10>
Some
Traceback (most recent call last):
File "keras_cnn_phoneme_original_fit_generator.py", line 222, in <module>
fws()
File "keras_cnn_phoneme_original_fit_generator.py", line 173, in fws
output = list_of_convolution[index](s[index])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in __call__
previous_mask = _collect_previous_mask(inputs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2703, in _collect_previous_mask
mask = node.output_masks[tensor_index]
IndexError: list index out of range
我做错了什么?
答案 0 :(得分:0)
您的索引错误来自list_of_convolution[index](s[index])
的调用,而不是任何一个索引。尝试分步写出来:
callable = list_of_convolution[index]
arg = s[index]
callable(arg) # <- this is where the error happens