NVIDIA / sentiment-discovery

Unsupervised Language Modeling at scale for robust sentiment classification
Other
1.06k stars 202 forks source link

KeyError in transformer model #68

Open MiKueen opened 4 years ago

MiKueen commented 4 years ago

Hi,

I'm using Windows 10, torch==1.4.0 and torchvision==0.5.0 When I run >python run_classifier.py --load transformer.pt , I get KeyError:


Creating mlstm
init BinaryClassifier with 4096 features
Traceback (most recent call last):
  File "run_classifier.py", line 82, in get_model
    model.load_state_dict(sd)
  File "D:\sentiment-discovery\model\sentiment_classifier.py", line 326, in load_state_dict
    self.lm_encoder.load_state_dict(state_dict['lm_encoder'], strict=strict)
KeyError: 'lm_encoder'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_classifier.py", line 244, in <module>
    main()
  File "run_classifier.py", line 224, in main
    model = get_model(args)
  File "run_classifier.py", line 89, in get_model
    model.lm_encoder.load_state_dict(sd)
  File "D:\sentiment-discovery\model\model.py", line 180, in load_state_dict
    self.encoder.load_state_dict(state_dict['encoder']['encoder'], strict=strict)
KeyError: 'encoder'
imomayiz commented 4 years ago

@MiKueen when working with a transformer classifier you should add the argument --model "transormer"