多输入双向 RNN 错误值错误?

Multi Input Bidirectional RNN Error Value Error?

所以我构建了一个带有串联的多输入模型,但出现值错误。我将在下面引用所有这些。

def bidir_model(x_train, x_test, y_train, y_test, meta, vocabulary_size, output):
    nlp_input = Input(shape=(388,), name='nlp_input')
    meta_input = Input(shape=(2,), name='meta_input')
    emb = Embedding(output_dim=vocabulary_size, input_dim=100, input_length=388)(nlp_input)
    nlp_out = Bidirectional(LSTM(128, dropout=0.3, recurrent_dropout=0.3, 
    kernel_regularizer=regularizers.l2(0.01)))(emb)
    x = concatenate([nlp_out, meta_input])
    x = Dense(150, activation='relu')(x)
    x = Dense(output, activation='softmax')(x)
    model = Model(inputs=[nlp_input , meta_input], outputs=[x])
    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) 
    ckpnt = ModelCheckpoint('model_bidir.h5', save_best_only=True, save_weights_only=True)
    model.fit([x_train, meta], y_train, validation_data=(x_test, y_test), batch_size=150, epochs=10, callbacks=[ckpnt])

我的 nlp 输入是一个用 tokenizer.text_to_sequences() 构建的序列,也用零填充。 meta_input 是一个包含我所有数字特征的数组,我收到此错误...

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays: [array([[ 0, 0, 0, ..., 139, 105, 478], [ 0, 0, 0, ..., 112, 3247, 21827], [ 0, 0, 0, ..., 91, 65372, 72], ..., [ 0, ...

它们肯定都是 numpy 数组。提前致谢 :)!

您的 validation_data 缺少 meta_input 的值。