-
Notifications
You must be signed in to change notification settings - Fork 75k
Description
from bert.tokenization import FullTokenizer
import pandas as pd
import tensorflow_hub as hub
bert_path = "https://tfhub.dev/tensorflow/bert_multi_cased_L-12_H-768_A-12/4"
sess = tf.Session()
def create_tokenizer_from_hub_module():
"""Get the vocab file and casing info from the Hub module."""
bert_module = hub.load(bert_path)
tokenization_info = bert_module(signature="tokenization_info", as_dict=True)
vocab_file, do_lower_case = sess.run(
[
tokenization_info["vocab_file"],
tokenization_info["do_lower_case"],
]
)
return FullTokenizer(vocab_file=vocab_file, do_lower_case=do_lower_case)
tokenizer = create_tokenizer_from_hub_module()
)
but in this line : tokenization_info = bert_module(signature="tokenization_info", as_dict=True)
I am getting error: ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (2 total):
* False
* None
Keyword arguments: {'do_lower_case': False, 'as_dict': True, 'signature': 'tokenization_info'}
Expected these arguments to match one of the following 4 option(s):
Option 1:
Positional arguments (3 total):
* {u'input_word_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_word_ids'), u'input_mask': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_mask'), u'input_type_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_type_ids')}
* False
* None
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* {u'input_word_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_word_ids'), u'input_mask': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_mask'), u'input_type_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_type_ids')}
* False
* None
Keyword arguments: {}
Option 3:
Positional arguments (3 total):
* {u'input_word_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_word_ids'), u'input_mask': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_mask'), u'input_type_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'inputs/input_type_ids')}
* True
* None
Keyword arguments: {}
Option 4:
Positional arguments (3 total):
* {u'input_word_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_word_ids'), u'input_mask': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_mask'), u'input_type_ids': TensorSpec(shape=(?, ?), dtype=tf.int32, name=u'input_type_ids')}
* True
* None
Keyword arguments: {}