Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model state_dict key missing 문제 #39

Open
hjlee9182 opened this issue Aug 17, 2022 · 1 comment
Open

model state_dict key missing 문제 #39

hjlee9182 opened this issue Aug 17, 2022 · 1 comment

Comments

@hjlee9182
Copy link

구글 드라이브에 있는
./experiments/base_model_with_crf/best-epoch-16-step-1500-acc-0.993.bin
./experiments/base_model_with_crf_val/best-epoch-12-step-1000-acc-0.960.bin
파일을 가지고 model load 하여 python inference.py를 실행하였을때

둘다 아래 에러가 발생합니다.
해결방법이 어떻게 될까요??

image

@Hans-digit
Copy link

Hans-digit commented Aug 26, 2022

net.py 에서

TorchCRF 라이브러리를 load 하지 마시고,

torchcrf 라이브러리를 install 받으시고 다음의 코드를 수정하시면 정상 작동 합니다.

class KobertCRF(nn.Module):
    """ KoBERT with CRF """
    def __init__(self, config, num_classes, vocab=None) -> None:
        super(KobertCRF, self).__init__()

        if vocab is None:
            self.bert, self.vocab = get_pytorch_kobert_model()
        else:
            self.bert = BertModel(config=BertConfig.from_dict(bert_config))
            self.vocab = vocab

        self.dropout = nn.Dropout(config.dropout)
        self.position_wise_ff = nn.Linear(config.hidden_size, num_classes)
        self.crf = CRF(num_tags=num_classes, batch_first=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants