bert
bert copied to clipboard
How to avoiding to use TFRecordWriter
When I predict with run_classifier.py, it always uses TFRecordWriter to write a temporary file from test examples. How to avoid it ?
def file_based_convert_examples_to_features(
examples, label_list, max_seq_length, tokenizer, output_file):
"""Convert a set of `InputExample`s to a TFRecord file."""
writer = tf.python_io.TFRecordWriter(output_file)
...
Thanks.
You have to modify "file_based_convert_examples_to_features" so that it returns the examples (yield feature). Add a function "input_fn_builder" instead of "file_based_input_fn_builder" and use "Dataset.from_tensor_slices"! However, this does not improve performance. TFRecordWriter is faster!