"server/vscode:/vscode.git/clone" did not exist on "1b97e084bf39ad5a6f8ddc0b540578ef8d059b6a"
Commit 0c984c50 authored by Chen Chen's avatar Chen Chen Committed by A. Unique TensorFlower
Browse files

Pass FLAGS.use_v2_feature_names as an argument to write_instance_to_example_files() method:

https://github.com/tensorflow/models/issues/9596

PiperOrigin-RevId: 349450359
parent 7786b741
...@@ -110,8 +110,8 @@ class TrainingInstance(object): ...@@ -110,8 +110,8 @@ class TrainingInstance(object):
def write_instance_to_example_files(instances, tokenizer, max_seq_length, def write_instance_to_example_files(instances, tokenizer, max_seq_length,
max_predictions_per_seq, output_files, max_predictions_per_seq, output_files,
gzip_compress): gzip_compress, use_v2_feature_names):
"""Create TF example files from `TrainingInstance`s.""" """Creates TF example files from `TrainingInstance`s."""
writers = [] writers = []
for output_file in output_files: for output_file in output_files:
writers.append( writers.append(
...@@ -148,7 +148,7 @@ def write_instance_to_example_files(instances, tokenizer, max_seq_length, ...@@ -148,7 +148,7 @@ def write_instance_to_example_files(instances, tokenizer, max_seq_length,
next_sentence_label = 1 if instance.is_random_next else 0 next_sentence_label = 1 if instance.is_random_next else 0
features = collections.OrderedDict() features = collections.OrderedDict()
if FLAGS.use_v2_feature_names: if use_v2_feature_names:
features["input_word_ids"] = create_int_feature(input_ids) features["input_word_ids"] = create_int_feature(input_ids)
features["input_type_ids"] = create_int_feature(segment_ids) features["input_type_ids"] = create_int_feature(segment_ids)
else: else:
...@@ -658,7 +658,8 @@ def main(_): ...@@ -658,7 +658,8 @@ def main(_):
write_instance_to_example_files(instances, tokenizer, FLAGS.max_seq_length, write_instance_to_example_files(instances, tokenizer, FLAGS.max_seq_length,
FLAGS.max_predictions_per_seq, output_files, FLAGS.max_predictions_per_seq, output_files,
FLAGS.gzip_compress) FLAGS.gzip_compress,
FLAGS.use_v2_feature_names)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment