繁体   English   中英

有人可以帮我找到代码中错误源的解决方案吗?

[英]Can someone help me find a solution to error source in my code?

我正在为 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 3.7等较低版本的 Python 并尝试安装特定且兼容的版本: pip install tensorflow==1.13.1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM