删减(文本):预期参数#0(基于零)为张量;got list(['烤蚂蚁在哥伦比亚很受欢迎')

2024-09-19 23:51:18 发布

您现在位置:Python中文网/ 问答频道 /正文

这是使用EMLo获取嵌入的代码

import tensorflow_hub as hub

import tensorflow as tf

elmo = hub.Module("https://tfhub.dev/google/elmo/2")

x = ["Roasted ants are a popular snack in Columbia"]


embeddings = elmo(x, signature="default", as_dict=True)["elmo"] # To Extract ELMo features 

embeddings.shape

我得到了这个类型错误,type error : pruned(text): expected argument #0(zero-based) to be a Tensor; got list (['Roasted ants are a popular snack in Columbia'])


Tags: 代码inimporttensorflowasarehubelmo