【发布时间】:2017-10-07 06:20:21
【问题描述】:
我目前收到一条错误消息,指出我超出了我正在迭代的列表的索引范围,但根本不是这种情况。 当我调用 conv1d(input) 时似乎出现了错误,但这些调用被存储在一个列表中,以避免编写多行代码被复制粘贴。
代码如下:
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
我做错了什么?
【问题讨论】: