我正在尝试命名实体识别,这里是我的 x_train 和 x_test 的详细信息:
Shape X_train: (3555, 120, 1024) Shape X_test: (887, 120, 1024)
input = Input(shape=(120,))
word_embedding_size = 1024
model = Embedding(input_dim=n_words, output_dim=word_embedding_size, input_length=120)(input)
model = Bidirectional(LSTM(units=word_embedding_size,
return_sequences=True,
dropout=0.5,
recurrent_dropout=0.5,
kernel_initializer=k.initializers.he_normal()))(model)
model = LSTM(units=word_embedding_size * 2,
return_sequences=True,
dropout=0.5,
recurrent_dropout=0.5,
kernel_initializer=k.initializers.he_normal())(model)
model = TimeDistributed(Dense(n_tags, activation="relu"))(model) # previously softmax output layer
crf = CRF(n_tags) # CRF layer
out = crf(model) # output
model = Model(input, out)
adam = k.optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.999)
model.compile(optimizer=adam, loss=crf.loss_function, metrics=[crf.accuracy, 'accuracy'])
model.summary()
model.fit(X_train , y_train, validation_data=(X_test, y_test), epochs=10, batch_size=32)
错误是:
ValueError: Input 0 of layer bidirectional_14 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 120, 1024, 1024)
请帮帮我,我无法通过其他答案解决。