namisan / mt-dnn

Multi-Task Deep Neural Networks for Natural Language Understanding
MIT License
2.24k stars 412 forks source link

predict.py size mismatch for scoring_list.0.weight and scoring_list.0.bias error #227

Closed akkefa closed 3 years ago

akkefa commented 3 years ago

@namisan Please help.

When I am running predict.py on test set for evaluation score using my mt-dnn trained model. I am facing this error. The reason I think they model architecture and checkpoints architecture are not the same.

Command: python predict.py --task="mdd" --task_id=0 --prep_input="data//mdd_test.json" --with_label --score="mdd_score.txt"

Error:

missing_keys, unexpected_keys = self.network.load_state_dict(state_dict['state'], strict=False)
  File "/Users/ikramali/.pyenv/versions/3.8.6/envs/ml/lib/python3.8/site-packages/torch/nn/modules/module.py", line 846, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for SANBertNetwork:
        size mismatch for scoring_list.0.weight: copying a param with shape torch.Size([2, 1024]) from checkpoint, the shape in current model is torch.Size([26, 1024]).
        size mismatch for scoring_list.0.bias: copying a param with shape torch.Size([2]) from checkpoint, the shape in current model is torch.Size([26]).

tasks.yml file:

fid: data_format: PremiseOnly n_class: 2 labels:

  • irony
  • not_irony task_type: Classification enable_san: False metric_meta:
  • F1 loss: CeCriterion

xnli: data_format: PremiseAndOneHypothesis enable_san: false labels:

  • contradiction
  • neutral
  • entailment metric_meta:
  • ACC loss: CeCriterion n_class: 3 task_type: Classification

mdd: data_format: PremiseOnly n_class: 26 labels:

  • RAB
  • DAM
  • BEI
  • DOH
  • JED
  • SFX
  • BAS
  • MOS
  • FES
  • BAG
  • ALG
  • ALX
  • JER
  • TRI
  • RIY
  • MSA
  • SAN
  • ALE
  • MUS
  • CAI
  • AMM
  • ASW
  • TUN
  • BEN
  • SAL
  • KHA task_type: Classification enable_san: False metric_meta:
  • F1MAC loss: CeCriterion
namisan commented 3 years ago

Make sure you use the same number of categories.