【问题标题】:Can someone help me find a solution to error source in my code?有人可以帮我找到代码中错误源的解决方案吗?
【发布时间】: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


【解决方案1】:

我不确定您使用的是什么模块,因为您没有提供任何模块,但我猜那是 tensorflow。尝试使用较低版本的 Python,例如 Python 3.7,并尝试安装特定且兼容的版本:pip install tensorflow==1.13.1

【讨论】:

  • 感谢您的回答。事实上,我正在使用 TensorFlow 。我已经尝试降级 TensorFlow 版本,但没有成功。
  • 感谢您的回复!你有超过 1 个 Python 版本吗?如果是这样,请确保该模块已安装在兼容版本中并且您使用的是兼容版本
  • 是的,现在可以使用了!谢谢你 RushBblyat!
猜你喜欢
  • 1970-01-01
  • 2021-07-10
  • 1970-01-01
  • 2022-06-13
  • 2016-07-09
  • 1970-01-01
  • 2021-09-22
  • 2019-09-23
相关资源
最近更新 更多