pruned(text): expected argument #0(zero-based) to be a Tensor; got list (['Roasted ants are a popular snack in Columbia'])

Viewed 1568

This is the code to get embeddings using 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

I'm getting this type error , type error : pruned(text): expected argument #0(zero-based) to be a Tensor; got list (['Roasted ants are a popular snack in Columbia']).

1 Answers

This code runs fine with Tensorflow 2.7 in colab,

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

Output:

TensorShape([Dimension(1), Dimension(8), Dimension(1024)])

Let us know which tensorflow version and environment are using to reproduce this error.

Related