bert icon indicating copy to clipboard operation
bert copied to clipboard

How to avoiding to use TFRecordWriter

Open ntson2002 opened this issue 7 years ago • 1 comments

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.

ntson2002 avatar Jan 23 '19 03:01 ntson2002

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!

rroderich avatar Feb 02 '19 09:02 rroderich