我正在尝试在 Keras 中训练单词级别的语言模型。
我有我的 X 和 Y,两者都具有形状(90582L、517L)
当我尝试适合这个模型时:
print('Build model...')
model = Sequential()
model.add(GRU(512, return_sequences=True, input_shape=(90582, 517)))
model.add(Dropout(0.2))
model.add(GRU(512, return_sequences=True))
model.add(Dropout(0.2))
model.add(TimeDistributedDense(1))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
model.fit(x_pad, y_pad, batch_size=128, nb_epoch=2)
我得到错误:
Exception: Error when checking model input:
expected gru_input_7 to have 3 dimensions, but got array with shape (90582L, 517L)
我需要一些关于输入形状应该是什么的指导?我已经对各种组合进行了反复试验,但似乎我误解了一些基本的东西。
在 Keras 文本生成示例中,X 矩阵有 3 个维度。我不知道第三维应该是什么。