tensorflow/text

AttributeError: 'Tensor' object has no attribute 'numpy'

ShivangiGheewala opened this issue · 2 comments

Traceback (most recent call last):
File "data_preprocessing_bert_based.py", line 301, in
tokenizer = create_tokenizer_from_hub_module()
File "data_preprocessing_bert_based.py", line 45, in create_tokenizer_from_hub_module
vocab_file = bert_layer.resolved_object.vocab_file.asset_path.numpy()
File "/home/syg/.local/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 446, in getattr
self.getattribute(name)

This isn't a problem with the tensorflow_text library, but I'll try to help you out.

This is similar to #391. The statement is running in graph mode instead of eager mode. You said that enabling eager execution didn't help. Do you also have these commands from within a tf.function()? This creates a graph object from inside the eager execution.

Thanks very much Robert!! Yes, I was trying to run it in graph mode. But I changed those and am able to resolve the problem.