这是使用 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'])。
小智 0
这段代码在 colab 中运行良好Tensorflow 2.7,
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)
输出:
TensorShape([Dimension(1), Dimension(8), Dimension(1024)])
Run Code Online (Sandbox Code Playgroud)
让我们知道正在使用哪个tensorflow版本environment来重现此错误。
| 归档时间: |
|
| 查看次数: |
578 次 |
| 最近记录: |