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

Add backwards compatibility for loading prediction head #159

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

tholor
Copy link
Member

@tholor tholor commented Nov 21, 2019

In older versions of FARM the TextClassificationHead had the parameter "balanced_weights" which also got stored in the .bin. Loading these older models in the recent version of FARM gives:


  File "../torch/nn/modules/module.py", line 839, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for TextClassificationHead:
	Unexpected key(s) in state_dict: "balanced_weights". 

This is due to torch.nn.module.load_state_dict(), which has a strict flag that handles if a model can be loaded even though there are different keys. Let's allow changing this flag from FARM's load methods to allow backward compatibility.

@tholor tholor self-assigned this Nov 21, 2019
@tholor tholor added the enhancement New feature or request label Nov 21, 2019
@tholor tholor merged commit 0b750d2 into master Nov 21, 2019
@tholor tholor deleted the add_compatibility_model_loading branch April 28, 2020 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants