Skip to content

fix(models): MLPRegression reads its hyperparameters from self.params, so HPO never reaches training - #873

Open
Maarmapa wants to merge 1 commit into
DashAISoftware:developfrom
Maarmapa:fix/mlp-regression-hpo-params
Open

fix(models): MLPRegression reads its hyperparameters from self.params, so HPO never reaches training#873
Maarmapa wants to merge 1 commit into
DashAISoftware:developfrom
Maarmapa:fix/mlp-regression-hpo-params

Conversation

@Maarmapa

Copy link
Copy Markdown
Contributor

MLPRegression kept its configuration in two places: self.params, the dict of construction kwargs, which is what train, save and load read; and instance attributes, which is what ModelFactory._process_param and both optimizers write via setattr(obj, key, value).

A search over hidden_size, activation, learning_rate or epochs therefore never reached the network: every trial rebuilt the construction-time model, the study reported a best trial, and the model it produced had never been trained with the values that won. Nothing failed while that was true.

Mirror the configuration onto instance attributes in __init__ and read those everywhere. Two smaller defects fall out of the same split and are fixed here too:

  • hidden_size fell back to 100 in train and to 5 in load, against a schema that declares 16. _CONFIG_DEFAULTS is now the single home for every fallback, and a test pins it to the schema field by field.
  • save persisted the construction kwargs next to post-search weights, so reloading rebuilt a network of the wrong width. It now records the configuration the model actually ran with.

Also fixes an AttributeError that made the model unusable outside ModelFactory: train reads self.log_train_every_n_steps and its three siblings, which __init__ never set.

Adds tests/back/models/test_mlp_regression.py, including one that drives a real OptunaOptimizer over hidden_size and asserts the widths of the networks actually built equal the widths Optuna suggested.

Closes #842

Claude-Session: https://claude.ai/code/session_01BzZ6td4VJdRDe76UndWZY3

Summary

Short explanation of what changed and why.


Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

Briefly list the important modified files and what was done.

Example:

  • path/to/file.py: description
  • another/file.tsx: description

Testing (optional)

Only add if there's something reviewers should verify.


Notes (optional)

Additional context or considerations.

MLPRegression kept its configuration in two places: `self.params`, the dict
of construction kwargs, which is what `train`, `save` and `load` read; and
instance attributes, which is what ModelFactory._process_param and both
optimizers write via `setattr(obj, key, value)`.

A search over hidden_size, activation, learning_rate or epochs therefore
never reached the network: every trial rebuilt the construction-time model,
the study reported a best trial, and the model it produced had never been
trained with the values that won. Nothing failed while that was true.

Mirror the configuration onto instance attributes in `__init__` and read
those everywhere. Two smaller defects fall out of the same split and are
fixed here too:

- `hidden_size` fell back to 100 in `train` and to 5 in `load`, against a
  schema that declares 16. `_CONFIG_DEFAULTS` is now the single home for
  every fallback, and a test pins it to the schema field by field.
- `save` persisted the construction kwargs next to post-search weights, so
  reloading rebuilt a network of the wrong width. It now records the
  configuration the model actually ran with.

Also fixes an AttributeError that made the model unusable outside
ModelFactory: `train` reads `self.log_train_every_n_steps` and its three
siblings, which `__init__` never set.

Adds tests/back/models/test_mlp_regression.py, including one that drives a
real OptunaOptimizer over hidden_size and asserts the widths of the networks
actually built equal the widths Optuna suggested.

Closes DashAISoftware#842

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzZ6td4VJdRDe76UndWZY3
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.

1 participant