我已经将universal Session encoder 2下载到一台没有互联网接入的计算机上,并解压缩到一个目标文件夹:“data”
import tensorflow as tf
import tensorflow_hub as hub
USE_embedder = hub.load(r'data/')
如果我像往常一样运行USE_embedder(['test'])
,我会得到错误:TypeError: 'Autotrackable' object is not callable.
但是按照tensorflow文档,我认为我可以运行:
USE_embedder.signatures['default'](['test'])
但是我得到了类型错误:
TypeError: pruned(text: expected argument #0(zero-based to be a Tensor; got list(['test'])
当我可以从联网的计算机上运行它,从https://tfhub.dev/google/universal-sentence-encoder/2加载而不是提取的下载,我就可以很好地运行这样的东西。如何使模型能够嵌入文档中通常显示的文本(例如,USE_embedder(['text'])
返回向量)
使用:Python 3.6.7、Tensorflow 2.4.1、Tensorflow_hub 0.11.0
当您将列表转换为张量时,它应该起作用:
(使用TF 2.4.1、tensorflow_轮毂0.11.0进行测试)
相关问题 更多 >
编程相关推荐