Issue type
Support
Have you reproduced the bug with TensorFlow Nightly?
No
Source
source
TensorFlow version
2.13
Custom code
Yes
OS platform and distribution
No response
Mobile device
No response
Python version
No response
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
This is the code from you manual and I really don't understans that I get this error. Why is it?
If I add
tf.compat.v1.disable_eager_execution()
tf.compat.v1.disable_v2_behavior()
I get
RuntimeError: input_dataset: Attempting to capture an EagerTensor without building a function.
Standalone code to reproduce the issue
data = tf.data.TextLineDataset([SENTENCES_PATH, TAGS_PATH])
from tensorflow_text.tools.wordpiece_vocab import bert_vocab_from_dataset as bert_vocab
tokens = bert_vocab.bert_vocab_from_dataset(
data,
# The target vocabulary size
vocab_size = 50000,
# Reserved tokens that must be included in the vocabulary
reserved_tokens=["[PAD]", "[UNK]", "[START]", "[END]"],
# Arguments for `text.BertTokenizer`
bert_tokenizer_params=dict(lower_case=True),
# Arguments for `wordpiece_vocab.wordpiece_tokenizer_learner_lib.learn`
learn_params={},
)
Relevant log output
TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key.
Issue type
Support
Have you reproduced the bug with TensorFlow Nightly?
No
Source
source
TensorFlow version
2.13
Custom code
Yes
OS platform and distribution
No response
Mobile device
No response
Python version
No response
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
This is the code from you manual and I really don't understans that I get this error. Why is it?
If I add
tf.compat.v1.disable_eager_execution()
tf.compat.v1.disable_v2_behavior()
I get
RuntimeError: input_dataset: Attempting to capture an EagerTensor without building a function.
Standalone code to reproduce the issue
data = tf.data.TextLineDataset([SENTENCES_PATH, TAGS_PATH]) from tensorflow_text.tools.wordpiece_vocab import bert_vocab_from_dataset as bert_vocab tokens = bert_vocab.bert_vocab_from_dataset( data, # The target vocabulary size vocab_size = 50000, # Reserved tokens that must be included in the vocabulary reserved_tokens=["[PAD]", "[UNK]", "[START]", "[END]"], # Arguments for `text.BertTokenizer` bert_tokenizer_params=dict(lower_case=True), # Arguments for `wordpiece_vocab.wordpiece_tokenizer_learner_lib.learn` learn_params={}, )Relevant log output
TypeError: Tensor is unhashable. Instead, use tensor.ref() as the key.