lipiji / SongNet

Code for ACL 2020 paper "Rigid Formats Controlled Text Generation":https://www.aclweb.org/anthology/2020.acl-main.68/
MIT License
230 stars 40 forks source link

运行./test.sh时发生报错: #24

Closed Asuka0002 closed 3 years ago

Asuka0002 commented 3 years ago

你好 我在训练网络完毕之后 将test.py中的m_path改为了结果中最新的checkpoint的地址

但是在运行./test.sh时发生报错: Traceback (most recent call last): File "test.py", line 34, in lm_model, lm_vocab, lm_args = init_model(m_path, gpu, "./model/vocab.txt") File "test.py", line 28, in init_model lm_model.load_state_dict(ckpt['model']) File "/usr/local/anaconda3/envs/GPT/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for BIGLM: size mismatch for tok_embed.weight: copying a param with shape torch.Size([6410, 768]) from checkpoint, the shape in current model is torch.Size([28781, 768]).
size mismatch for out_proj.weight: copying a param with shape torch.Size([6410, 768]) from checkpoint, the shape in current model is torch.Size([28781, 768]). size mismatch for out_proj.bias: copying a param with shape torch.Size([6410]) from checkpoint, the shape in current model is torch.Size([28781]).

请问这是什么原因导致的呢?非常感谢

lipiji commented 3 years ago

你好,加载的哪个模型,我看看

Asuka0002 commented 3 years ago

我自己训的一个模型 ,是vocab维度出了问题。 已经解决,非常感谢