Skip to content

KeyError in transformer model #68

@MiKueen

Description

@MiKueen

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions