这是使用 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
Run Code Online (Sandbox Code Playgroud)
我收到这种类型的错误,type error : pruned(text): expected argument #0(zero-based) to be a Tensor; got list (['Roasted ants are a popular snack in Columbia'])。