我开始使用以下 Kaggle 内核:
之后,我使用了以下即将接近的代码:
bert_config = modeling.BertConfig.from_json_file(bert_config_file)
processor = ColaProcessor()
label_list = processor.get_labels()
tokenizer = tokenization.FullTokenizer(vocab_file=vocab_file, do_lower_case=do_lower_case)
tpu_cluster_resolver = None
is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2
train_examples = processor.get_train_examples(data_dir)
num_train_steps = int(len(train_examples) / train_batch_size * num_train_epochs)
num_warmup_steps = int(num_train_steps * warmup_proportion)
print("Feature Test")
features = convert_examples_to_features(examples=train_examples, label_list=label_list, max_seq_length=max_seq_length, tokenizer=tokenizer)
print("Feature Test Completed")
执行此操作后,我的features
变量得到以下输出:
<run_classifier.InputFeatures at 0x7f798eece780>,
<run_classifier.InputFeatures at 0x7f798eefd7b8>,
<run_classifier.InputFeatures at 0x7f798eece5c0>,
<run_classifier.InputFeatures at 0x7f798eecec18>,
<run_classifier.InputFeatures at 0x7f798eece978>,
<run_classifier.InputFeatures at 0x7f798eeced68>,
<run_classifier.InputFeatures at 0x7f798eece208>,
<run_classifier.InputFeatures at 0x7f798eecea58>,
我的困惑是如何将其转换为可用于其他任务的嵌入数组。我可能会错过伯特的工作方式。