diff --git a/examples/run_classifier.py b/examples/run_classifier.py index fb78b6efeb7..d79c2526b07 100644 --- a/examples/run_classifier.py +++ b/examples/run_classifier.py @@ -857,7 +857,6 @@ def main(): optimizer.zero_grad() global_step += 1 - if args.do_train: # Save a trained model and the associated configuration model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self output_model_file = os.path.join(args.output_dir, WEIGHTS_NAME) diff --git a/examples/run_squad.py b/examples/run_squad.py index a29362ffb97..bb335ce75c9 100644 --- a/examples/run_squad.py +++ b/examples/run_squad.py @@ -471,7 +471,7 @@ def write_predictions(all_examples, all_features, all_results, n_best_size, prelim_predictions = [] # keep track of the minimum score of null start+end of position 0 score_null = 1000000 # large and positive - min_null_feature_index = 0 # the paragraph slice with min mull score + min_null_feature_index = 0 # the paragraph slice with min null score null_start_logit = 0 # the start logit at the slice with min null score null_end_logit = 0 # the end logit at the slice with min null score for (feature_index, feature) in enumerate(features): @@ -620,7 +620,7 @@ def write_predictions(all_examples, all_features, all_results, n_best_size, all_predictions[example.qas_id] = "" else: all_predictions[example.qas_id] = best_non_null_entry.text - all_nbest_json[example.qas_id] = nbest_json + all_nbest_json[example.qas_id] = nbest_json with open(output_prediction_file, "w") as writer: writer.write(json.dumps(all_predictions, indent=4) + "\n") @@ -657,8 +657,8 @@ def get_final_text(pred_text, orig_text, do_lower_case, verbose_logging=False): # # What we really want to return is "Steve Smith". # - # Therefore, we have to apply a semi-complicated alignment heruistic between - # `pred_text` and `orig_text` to get a character-to-charcter alignment. This + # Therefore, we have to apply a semi-complicated alignment heuristic between + # `pred_text` and `orig_text` to get a character-to-character alignment. This # can fail in certain cases in which case we just return `orig_text`. def _strip_spaces(text): diff --git a/examples/run_swag.py b/examples/run_swag.py index 2ebd637223c..ab8e147cae9 100644 --- a/examples/run_swag.py +++ b/examples/run_swag.py @@ -15,6 +15,8 @@ # limitations under the License. """BERT finetuning runner.""" +from __future__ import absolute_import + import argparse import csv import logging @@ -31,7 +33,7 @@ from torch.utils.data.distributed import DistributedSampler from tqdm import tqdm, trange from pytorch_pretrained_bert.file_utils import PYTORCH_PRETRAINED_BERT_CACHE -from pytorch_pretrained_bert.modeling import BertForMultipleChoice +from pytorch_pretrained_bert.modeling import (BertForMultipleChoice, BertConfig, WEIGHTS_NAME, CONFIG_NAME) from pytorch_pretrained_bert.optimization import BertAdam, warmup_linear from pytorch_pretrained_bert.tokenization import BertTokenizer diff --git a/pytorch_pretrained_bert/modeling_gpt2.py b/pytorch_pretrained_bert/modeling_gpt2.py index 69bd088a4e7..c381b288f86 100644 --- a/pytorch_pretrained_bert/modeling_gpt2.py +++ b/pytorch_pretrained_bert/modeling_gpt2.py @@ -15,6 +15,8 @@ # limitations under the License. """PyTorch OpenAI GPT-2 model.""" +from __future__ import absolute_import, division, print_function, unicode_literals + import collections import copy import json diff --git a/pytorch_pretrained_bert/modeling_openai.py b/pytorch_pretrained_bert/modeling_openai.py index d73ee66f50c..296abbfc314 100644 --- a/pytorch_pretrained_bert/modeling_openai.py +++ b/pytorch_pretrained_bert/modeling_openai.py @@ -15,6 +15,8 @@ # limitations under the License. """PyTorch OpenAI GPT model.""" +from __future__ import absolute_import, division, print_function, unicode_literals + import collections import copy import json diff --git a/pytorch_pretrained_bert/modeling_transfo_xl.py b/pytorch_pretrained_bert/modeling_transfo_xl.py index b225316f3d8..ac895a03a7e 100644 --- a/pytorch_pretrained_bert/modeling_transfo_xl.py +++ b/pytorch_pretrained_bert/modeling_transfo_xl.py @@ -18,6 +18,8 @@ In particular https://github.com/kimiyoung/transformer-xl/blob/master/pytorch/mem_transformer.py """ +from __future__ import absolute_import, division, print_function, unicode_literals + import os import copy import json