MLPRegression.__init__ stores its whole configuration in a dict:
# DashAI/back/models/scikit_learn/mlp_regression.py:400
self.params = kwargs
and train() reads every hyperparameter back out of that dict:
# same file, lines 452-463
hidden_size=self.params.get("hidden_size", 100),
activation_name=self.params.get("activation", "relu"),
optimizer = torch.optim.Adam(self.model.parameters(), lr=self.params.get("learning_rate", 0.001))
total_epochs = self.params.get("epochs", 3)
But the optimizer applies suggested values as instance attributes:
# DashAI/back/optimizers/optuna_optimizer.py:277
setattr(obj, key, value)
self.params never sees them, so during HPO every trial trains an identical
model and the study optimizes noise. setattr never fails, so nothing
surfaces it.
Verified by execution on develop @ b3b7296: after
setattr(mdl, "learning_rate", 0.9), the instance attribute is 0.9 while
self.params["learning_rate"] is still 0.001 — and train() reads the
latter. The same applies to optuna_optimizer.py:315, where the winning
parameters are written back after the study.
This is the only model in the repo with this pattern. Its siblings assign to
instance attributes and read them directly — mlp_image_classifier.py:430-431
sets self.epochs / self.learning_rate and train() reads self.epochs at
line 541, so setattr reaches training as intended.
A related detail found on the way: train() falls back to
hidden_size=100 (line 452) while load() rebuilds the network with
hidden_size=5. A checkpoint saved without that key cannot be loaded back —
the state dict shapes will not match.
Suggested fix: read hyperparameters from instance attributes like the
sibling models do, or mirror kwargs onto attributes in __init__ so both
access paths agree. Happy to send a PR with tests either way — just say which
shape you prefer.
MLPRegression.__init__stores its whole configuration in a dict:and
train()reads every hyperparameter back out of that dict:But the optimizer applies suggested values as instance attributes:
self.paramsnever sees them, so during HPO every trial trains an identicalmodel and the study optimizes noise.
setattrnever fails, so nothingsurfaces it.
Verified by execution on
develop@b3b7296: aftersetattr(mdl, "learning_rate", 0.9), the instance attribute is0.9whileself.params["learning_rate"]is still0.001— andtrain()reads thelatter. The same applies to
optuna_optimizer.py:315, where the winningparameters are written back after the study.
This is the only model in the repo with this pattern. Its siblings assign to
instance attributes and read them directly —
mlp_image_classifier.py:430-431sets
self.epochs/self.learning_rateandtrain()readsself.epochsatline 541, so
setattrreaches training as intended.A related detail found on the way:
train()falls back tohidden_size=100(line 452) whileload()rebuilds the network withhidden_size=5. A checkpoint saved without that key cannot be loaded back —the state dict shapes will not match.
Suggested fix: read hyperparameters from instance attributes like the
sibling models do, or mirror
kwargsonto attributes in__init__so bothaccess paths agree. Happy to send a PR with tests either way — just say which
shape you prefer.