Keras BLSTM AssertionError len(input_shape)> = 3

时间:2018-12-01 21:17:12

标签: python keras lstm

我正在尝试使用Keras进行双向LSTM模型的音素提取任务。我拥有的训练数据包括3696个2d NumPy数组的列表,每个数组都有26行和200-700列。我还是神经网络的新手。

这是我遇到的错误:

File ".../keras/engine/base_layer.py", line 431, in __call__
File ".../keras/layers/wrappers.py", line 195, in build
assert len(input_shape) >= 3
Assertion Error

这是我的代码:

input_data = Input(shape=(26,))
x = GaussianNoise(std)(input_data)
x = TimeDistributed(Dense(26))(x)
x = Bidirectional(LSTM(93))(x)
x = Bidirectional(LSTM(93))(x)
y_pred = TimeDistributed(Dense(61, activation='softmax'))(x)
labels = Input(name='the_labels', shape=[None,], dtype='int32')
input_length = Input(name='input_length', shape=[1], dtype='int32')
label_length = Input(name='label_length', shape=[1], dtype='int32')

loss_out = Lambda(ctc_lambda_func, output_shape=(1,), name='ctc')([y_pred,
                                                                   labels,
                                                                   input_length,
                                                                   label_length])

model = Model(inputs=[input_data, labels, input_length, label_length], outputs=[loss_out])

此行发生错误:

x = TimeDistributed(Dense(26))(x)

为什么会出现此错误?

0 个答案:

没有答案