Tencent / NeuralNLP-NeuralClassifier

An Open-source Neural Hierarchical Multi-label Text Classification Toolkit
Other
1.85k stars 406 forks source link

RuntimeError: Error(s) in loading state_dict for TextRCNN: #96

Closed wuyou521 closed 3 years ago

wuyou521 commented 3 years ago

(mypytorch) F:\NeuralNLP-NeuralClassifier-master>python eval.py conf/train.json Traceback (most recent call last): File "eval.py", line 113, in eval(config) File "eval.py", line 77, in eval load_checkpoint(conf.eval.model_dir, conf, model, optimizer) File "eval.py", line 56, in load_checkpoint model.load_state_dict(checkpoint["state_dict"]) File "F:\Anaconda\envs\mypytorch\lib\site-packages\torch\nn\modules\module.py", line 1407, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for TextRCNN: Missing key(s) in state_dict: "rnn.rnn.weight_ih_l0", "rnn.rnn.weight_hh_l0", "rnn.rnn.bias_ih_l0", "rnn.rnn.bias_hh_l0", "rnn.rnn.weight_ih_l0_reverse", "rnn.rnn.weight_hh_l0_reverse", "rnn.rnn.bias_ih_l0 _reverse", "rnn.rnn.bias_hh_l0_reverse". size mismatch for convs.0.weight: copying a param with shape torch.Size([100, 64, 2]) from checkpoint, the shape in current model is torch.Size([100, 128, 2]). size mismatch for convs.1.weight: copying a param with shape torch.Size([100, 64, 3]) from checkpoint, the shape in current model is torch.Size([100, 128, 3]). size mismatch for convs.2.weight: copying a param with shape torch.Size([100, 64, 4]) from checkpoint, the shape in current model is torch.Size([100, 128, 4]).

wuyou521 commented 3 years ago

just because wrong data_model_dir

"eval": { "text_file": "data/BC7test.json", "threshold": 0.5, "dir": "eval_dir", "batch_size": 1024, "is_flat": true, "top_k": 7, "model_dir": "checkpoint_dir_rcv1/DPCNN_best"