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

Serialize multi_label_threshold for classification models #2368

Merged
merged 5 commits into from Aug 17, 2021

Conversation

yosipk
Copy link
Collaborator

@yosipk yosipk commented Aug 10, 2021

Closes #2367

@@ -145,6 +146,7 @@ def _init_model_with_state_dict(state):
label_dictionary=state["label_dictionary"],
label_type=state["label_type"],
multi_label=state["multi_label"],
multi_label_threshold=0.5 if "multi_label_threshold" not in state.keys() else state["multi_label_threshold"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of default 0.5 the defaults can be read from the class:

super_defaults = inspect.signature(super(TextPairClassifier, self).__init__)
multi_label_threshold_default = super_defaults.parameters['multi_label_threshold'].default

and then use multi_label_threshold_default instead of 0.5.

@@ -101,6 +102,7 @@ def _init_model_with_state_dict(state):
label_dictionary=state["label_dictionary"],
label_type=label_type,
multi_label=state["multi_label"],
multi_label_threshold=0.5 if "multi_label_threshold" not in state.keys() else state["multi_label_threshold"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of default 0.5 the defaults can be read from the class:

super_defaults = inspect.signature(super(TextClassifier, self).__init__)
multi_label_threshold_default = super_defaults.parameters['multi_label_threshold'].default

and then use multi_label_threshold_default instead of 0.5.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool didn't know about this!

@alanakbik
Copy link
Collaborator

@yosipk thanks for adding this!

@alanakbik alanakbik merged commit 288f7ce into master Aug 17, 2021
@alanakbik alanakbik deleted the GH-2367-serialize-multi-label-threshold branch August 17, 2021 14:24
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

Successfully merging this pull request may close these issues.

Serializing the multi_label_threshold along with the classification models
2 participants