【问题标题】:Elmo embeddings errorsElmo 嵌入错误
【发布时间】:2021-07-26 11:31:18
【问题描述】:

我正在使用 ELMO 为我的数据集创建嵌入,我总是收到此错误:

embed=elmo(data,signature="default",as_dict=True)["elmo"]
TypeError: 'AutoTrackable' object is not callable 

我的代码就这么简单:

import tensorflow_hub as hub
import tensorflow as tf
elmo = hub.load("https://tfhub.dev/google/elmo/3")
embeddings = elmo(
    ["the cat is on the mat", "dogs are in the fog"],
    signature="default",
    as_dict=True)["elmo"]

【问题讨论】:

    标签: python tensorflow nlp embedding elmo


    【解决方案1】:

    问题出在 TensorFlow 版本上。 ELMo 不适用于 tensorflow 2,请参阅 TensorFlow Hub 文档以检查 version 1version 2 中支持的文本嵌入。将 TensorFlow 版本更改为 1.15 后运行相同的代码即可。您还应该使用版本 1 的 hub.Module()(而不是 hub.load)。请参考this post了解如何更改版本。

    【讨论】:

      猜你喜欢
      • 2019-05-03
      • 1970-01-01
      • 2019-05-16
      • 2023-03-03
      • 2021-07-24
      • 1970-01-01
      • 2019-04-03
      • 1970-01-01
      • 2020-10-28
      相关资源
      最近更新 更多