我正在为NER任务训练BI-LSTM-CRF模型。我能够建立模型,但是当我将其与训练数据相匹配时,googlecolab给了我一个错误。
下面是我的模型的代码(或者这里:我的模型的代码):
input_layer = layers.Input(shape=(MAX_SENTENCE,))
model = layers.Embedding(WORD_COUNT, DENSE_EMBEDDING, embeddings_initializer="uniform", input_length=MAX_SENTENCE)(input_layer)
model = layers.Bidirectional(layers.LSTM(LSTM_UNITS, recurrent_dropout=LSTM_DROPOUT, return_sequences=True))(model)
model = layers.TimeDistributed(layers.Dense(DENSE_UNITS, activation="relu"))(model)
crf_layer = CRF(units=TAG_COUNT)
output_layer = crf_layer(model)
ner_model = Model(input_layer, output_layer)
loss = losses.crf_loss
acc_metric = metrics.crf_accuracy
opt = tf.keras.optimizers.Adam(learning_rate=0.001)
ner_model.compile(optimizer=opt, loss=loss, metrics=[acc_metric])
ner_model.summary()
然后在拟合模型后,我得到以下错误:
AttributeError: 'Tensor' object has no attribute '_keras_history' ([error message for google colab][2])
下面是我的依赖项列表:
有人能帮我一下吗?
我不确定你使用什么模块,因为你没有提供任何,但我猜那是tensorflow
。尝试使用较低版本的Python,如Python 3.7
,并尝试安装特定的和兼容的版本:pip install tensorflow==1.13.1