【发布时间】:2021-10-30 10:54:59
【问题描述】:
我正在为 NER 任务训练 BI-LSTM-CRF 模型。我能够构建模型,但是当我将其与训练数据相匹配时,googlecolab 会抛出一个错误。
下面是我的模型的代码(或这里:code for my model):
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])
这是我的依赖列表:Dependencies
有人可以帮帮我吗?
【问题讨论】:
-
标题不是最好的。在这里提出问题的每个人都在寻找与编程相关的解决方案。使您的标题针对您的问题以引起更多关注。
-
好的,知道了。谢谢!
标签: python tensorflow deep-learning tensor named-entity-recognition