RNN:具有不同输入和输出的预测

时间:2018-03-03 10:32:25

标签: python numpy machine-learning keras recurrent-neural-network

我正在尝试在矢量化文本上运行RNN / LSTM网络。 我已将数据结构化为一个numpy 3D数组,结构如下:

X_train = (117 quantity of objects, 73742 length of text (quantity of chars), 118 (size of dictionary))
y_train = (117 quantity of objects, 73744 length of text (quantity of chars), 118 (size of dictionary))

与y文本的标记相关的差异(我尝试解决名称实体识别的任务)

我用

建立模型
model = Sequential()
model.add(Bidirectional(LSTM(20, return_sequences=True),
                input_shape=y_train.shape[1:]))
model.add(Bidirectional(LSTM(10, return_sequences=True)))
model.add(Dense(118))
model.compile(loss='mae', 
      optimizer='rmsprop')

model.summary()

但是在跑完

之后
model.fit(x_train, y_train, epochs = 30, batch_size = 32, 
  validation_data =(x_val, y_val))

它给我一个错误

ValueError: Error when checking input: expected bidirectional_30_input to have shape (73744, 118) but got array with shape (73742, 118)

我该如何解决?

0 个答案:

没有答案