未だにチェックポイントデータの変換できず

Python内からデータを読み込もうとしても結局同じエラーで止まってしまう。

 

from transformers import BertConfig, BertForPreTraining, BertTokenizer, BertModel

bertconfig = BertConfig()
bertconfig.vocab_size = 32768
bertconfig.max_position_embeddings = 128

bertmodelforpretraining = BertForPreTraining(bertconfig)


DIR_BERT ='bert-base/'
BASE_CKPT = 'ctl_step_1000000.ckpt-100'

bertmodelforpretraining.load_tf_weights(bertconfig, DIR_BERT + BASE_CKPT)

bertmodel = bertmodelforpretraining.bert

 

を実行すると、

 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15716\2240196136.py in <module>
     14 
---> 15 bertmodelforpretraining.load_tf_weights(bertconfig, DIR_BERT + BASE_CKPT)
     16 

c:\users\user\.pyenv\pyenv-win\versions\3.7.9\lib\site-packages\transformers\models\bert\modeling_bert.py in load_tf_weights_in_bert(model, config, tf_checkpoint_path)
    154             array = np.transpose(array)
    155         try:
--> 156             if pointer.shape != array.shape:
    157                 raise ValueError(f"Pointer shape {pointer.shape} and array shape {array.shape} mismatched")
    158         except AssertionError as e:

c:\users\user\.pyenv\pyenv-win\versions\3.7.9\lib\site-packages\torch\nn\modules\module.py in __getattr__(self, name)
   1176                 return modules[name]
   1177         raise AttributeError("'{}' object has no attribute '{}'".format(
-> 1178             type(self).__name__, name))
   1179 
   1180     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'BertForPreTraining' object has no attribute 'shape'

 

というエラーで止まってしまう。オブジェクトの型も色々変えてみたけれど、多少エラーの種類は違うものの、やはり読み込みが完了しない。う〜ん、分からん。しかし、ここが解決しないと一向に前に進まない。困ったものだ。