Open li1117heex opened 3 years ago
self.deberta = deberta.DeBERTa(pre_trained='base')
when pre_trained='base','larget','xlarge', throw Traceback (most recent call last): File "/home/v-weishengli/Downloads/pycharm-community-2020.2.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1448, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/v-weishengli/Downloads/pycharm-community-2020.2.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/v-weishengli/mydeberta/debertadeberta.py", line 2, in model=deberta.DeBERTa(pre_trained='large') File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 57, in init self.apply_state(state) File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 147, in apply_state current[c] = state[key_match(c, state.keys())] File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 143, in key_match assert len(c)==1, c AssertionError: []
xlargev2 normal.
Hellow, same problem. Use the following codes:
import torch
from DeBERTa.deberta import DeBERTa, ModelConfig
from collections import OrderedDict
conf = ModelConfig.from_json_file( r"public_pretrain_model\deberta_base\config.json")
m = DeBERTa(config=conf)
di = torch.load(r"public_pretrain_model\deberta_base\pytorch_model.bin",map_location="cpu")
di = OrderedDict([(k.replace("deberta.", ""), v) for k, v in di.items()])
load_info = m.load_state_dict(di, strict=False)
print(load_info)
Same problem here:
(deberta) jupyter@system:~$ python
Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03)
[GCC 10.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from DeBERTa import deberta
>>> d = deberta.DeBERTa(pre_trained='large')
12/05/2022 21:03:07|INFO|logging|00| Loaded pretrained model file /home/jupyter/.~DeBERTa/assets/latest/deberta-large/pytorch_model.bin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jupyter/mambaforge/envs/deberta/lib/python3.9/site-packages/DeBERTa/deberta/deberta.py", line 57, in __init__
self.apply_state(state)
File "/home/jupyter/mambaforge/envs/deberta/lib/python3.9/site-packages/DeBERTa/deberta/deberta.py", line 147, in apply_state
current[c] = state[key_match(c, state.keys())]
File "/home/jupyter/mambaforge/envs/deberta/lib/python3.9/site-packages/DeBERTa/deberta/deberta.py", line 143, in key_match
assert len(c)==1, c
AssertionError: []
>>>
self.deberta = deberta.DeBERTa(pre_trained='base')
when pre_trained='base','larget','xlarge', throw Traceback (most recent call last): File "/home/v-weishengli/Downloads/pycharm-community-2020.2.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1448, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/v-weishengli/Downloads/pycharm-community-2020.2.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/v-weishengli/mydeberta/debertadeberta.py", line 2, in
model=deberta.DeBERTa(pre_trained='large')
File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 57, in init
self.apply_state(state)
File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 147, in apply_state
current[c] = state[key_match(c, state.keys())]
File "/home/v-weishengli/mydeberta/venv/lib/python3.7/site-packages/DeBERTa/deberta/deberta.py", line 143, in key_match
assert len(c)==1, c
AssertionError: []
xlargev2 normal.