Skip to content

Commit 121f88c

Browse files
committed
update conversion scripts
1 parent d77abd4 commit 121f88c

9 files changed

+20
-9
lines changed

pytorch_transformers/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
__version__ = "1.2.0"
2+
# Work around to update TensorFlow's absl.logging threshold which alters the
3+
# default Python logging output behavior when present.
4+
# see: https://github.com/abseil/abseil-py/issues/99
5+
# and: https://github.com/tensorflow/tensorflow/issues/26691#issuecomment-500369493
6+
try:
7+
import absl.logging
8+
absl.logging.set_verbosity('info')
9+
absl.logging.set_stderrthreshold('info')
10+
absl.logging._warn_preinit_stderr = False
11+
except:
12+
pass
213

314
# Tokenizer
415
from .tokenization_utils import (PreTrainedTokenizer)

pytorch_transformers/convert_gpt2_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import torch
2323

24-
from pytorch_transformers.modeling_gpt2 import (CONFIG_NAME, WEIGHTS_NAME,
24+
from pytorch_transformers import (CONFIG_NAME, WEIGHTS_NAME,
2525
GPT2Config,
2626
GPT2Model,
2727
load_tf_weights_in_gpt2)

pytorch_transformers/convert_openai_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import torch
2323

24-
from pytorch_transformers.modeling_openai import (CONFIG_NAME, WEIGHTS_NAME,
24+
from pytorch_transformers import (CONFIG_NAME, WEIGHTS_NAME,
2525
OpenAIGPTConfig,
2626
OpenAIGPTModel,
2727
load_tf_weights_in_openai_gpt)

pytorch_transformers/convert_pytorch_checkpoint_to_tf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import torch
2121
import numpy as np
2222
import tensorflow as tf
23-
from pytorch_transformers.modeling import BertModel
23+
from pytorch_transformers import BertModel
2424

2525

2626
def convert_pytorch_checkpoint_to_tf(model:BertModel, ckpt_dir:str, model_name:str):

pytorch_transformers/convert_roberta_checkpoint_to_pytorch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
from fairseq.models.roberta import RobertaModel as FairseqRobertaModel
2525
from fairseq.modules import TransformerSentenceEncoderLayer
26-
from pytorch_transformers.modeling_bert import (BertConfig, BertEncoder,
26+
from pytorch_transformers import (BertConfig, BertEncoder,
2727
BertIntermediate, BertLayer,
2828
BertModel, BertOutput,
2929
BertSelfAttention,
3030
BertSelfOutput)
31-
from pytorch_transformers.modeling_roberta import (RobertaEmbeddings,
31+
from pytorch_transformers import (RobertaEmbeddings,
3232
RobertaForMaskedLM,
3333
RobertaForSequenceClassification,
3434
RobertaModel)

pytorch_transformers/convert_tf_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import argparse
2222
import torch
2323

24-
from pytorch_transformers.modeling_bert import BertConfig, BertForPreTraining, load_tf_weights_in_bert
24+
from pytorch_transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
2525

2626
import logging
2727
logging.basicConfig(level=logging.INFO)

pytorch_transformers/convert_transfo_xl_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import pytorch_transformers.tokenization_transfo_xl as data_utils
2727

2828
from pytorch_transformers import CONFIG_NAME, WEIGHTS_NAME
29-
from pytorch_transformers.modeling_transfo_xl import (TransfoXLConfig, TransfoXLLMHeadModel,
29+
from pytorch_transformers import (TransfoXLConfig, TransfoXLLMHeadModel,
3030
load_tf_weights_in_transfo_xl)
3131
from pytorch_transformers.tokenization_transfo_xl import (CORPUS_NAME, VOCAB_FILES_NAMES)
3232

pytorch_transformers/convert_xlm_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import torch
2424
import numpy
2525

26-
from pytorch_transformers.modeling_utils import CONFIG_NAME, WEIGHTS_NAME
26+
from pytorch_transformers import CONFIG_NAME, WEIGHTS_NAME
2727
from pytorch_transformers.tokenization_xlm import VOCAB_FILES_NAMES
2828

2929
import logging

pytorch_transformers/convert_xlnet_checkpoint_to_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import argparse
2323
import torch
2424

25-
from pytorch_transformers.modeling_xlnet import (CONFIG_NAME, WEIGHTS_NAME,
25+
from pytorch_transformers import (CONFIG_NAME, WEIGHTS_NAME,
2626
XLNetConfig,
2727
XLNetLMHeadModel, XLNetForQuestionAnswering,
2828
XLNetForSequenceClassification,

0 commit comments

Comments
 (0)