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

KeyError in transformer model #68

Open
MiKueen opened this issue Jan 23, 2020 · 1 comment
Open

KeyError in transformer model #68

MiKueen opened this issue Jan 23, 2020 · 1 comment

Comments

@MiKueen
Copy link

MiKueen commented Jan 23, 2020

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'
@MiKueen MiKueen changed the title KeyError while running transformer model KeyError in transformer model Jan 23, 2020
@imomayiz
Copy link

imomayiz commented Apr 6, 2020

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

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