AttributeError:调用CRF.call()时遇到异常。模块“keras.backend”没有属性“dot”

问题描述 投票:0回答:1

我正在构建 Bi-LSTM CRF 来完成 NER 任务。当说到

history = model.fit(
    X_train,
    np.array(y_train),
    batch_size=batch_size,
    epochs=epochs,
    validation_split=0.1,
    callbacks=[checkpointer])

弹出错误

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-43-f7b1ef4826d9> in <cell line: 1>()
----> 1 history = model.fit(
      2     X_train,
      3     np.array(y_train),
      4     batch_size=batch_size,
      5     epochs=epochs,

2 frames
/usr/local/lib/python3.10/dist-packages/keras_contrib/layers/crf.py in viterbi_decoding(self, X, mask)
    557 
    558     def viterbi_decoding(self, X, mask=None):
--> 559         input_energy = self.activation(K.dot(X, self.kernel) + self.bias)
    560         if self.use_boundary:
    561             input_energy = self.add_boundary_energy(

AttributeError: Exception encountered when calling CRF.call().

module 'keras.backend' has no attribute 'dot'

Arguments received by CRF.call():
  • X=tf.Tensor(shape=(None, 3000, 3), dtype=float32)
  • mask=None

我的完整代码是这里

我已经更新到最新的tensorflow和keras并且已经导入这些库

我的tensorflow版本是2.15.0

这个问题有什么解决办法吗?

python tensorflow keras deep-learning lstm
1个回答
0
投票

您能够解决该错误吗?我正在编写类似的代码并面临相同的错误

© www.soinside.com 2019 - 2024. All rights reserved.