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

fix: transform onehot encoder outputs to float32 tensor #3242

Merged
merged 2 commits into from
Mar 14, 2023
Merged

Conversation

abidwael
Copy link
Contributor

When we specify a onehot encoder for category features and have dense layers down the line, we get the following error

RuntimeError: mat1 and mat2 must have the same dtype

This PR makes sure to convert the outputs of the onehot encoder to float32

@abidwael abidwael requested a review from tgaddair March 14, 2023 00:30
Comment on lines 203 to 217
def test_onehot_category_encoder():
config = {
"defaults": {"category": {"encoder": {"type": "onehot"}}},
"input_features": [
{"name": "MSSubClass", "type": "category"},
{"name": "MSZoning", "type": "category"},
{"name": "Street", "type": "category"},
{"name": "Neighborhood", "type": "category"},
],
"model_type": "ecd",
"output_features": [{"name": "SalePrice", "type": "number"}],
"trainer": {"train_steps": 1},
"combiner": {"type": "concat", "num_fc_layers": 2},
}
ModelConfig.from_dict(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

@abidwael does just doing .from_dict() repro the error? I would image this would require at least 1-2 steps of training for the error in your PR comment to be reproed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, it doesn't. Will remove this test as it will be captured in #2991

Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably add a test here as well since these will run on every commit, whereas the tests in #2991 will run on merge to master? or is that not the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will run on every commit

@github-actions
Copy link

Unit Test Results

         6 files  ±    0           6 suites  ±0   7h 26m 7s ⏱️ - 6m 19s
  4 077 tests +  46    4 034 ✔️ +  46    43 💤 +1  0  - 1 
12 201 runs  +115  12 069 ✔️ +110  132 💤 +6  0  - 1 

Results for commit 9c3ccdc. ± Comparison against base commit aa49636.

@abidwael abidwael merged commit da2d6d3 into master Mar 14, 2023
@abidwael abidwael deleted the onehot-mat branch March 14, 2023 20:38
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.

None yet

2 participants