Elmo 嵌入错误

我正在使用 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"],as_dict=True)["elmo"]
jishuailove 回答:Elmo 嵌入错误

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

本文链接:https://www.f2er.com/35887.html

大家都在问