A Bayesian Optimization/ Tree Structured Parzen Estimator approach to Hyperparameter Tuning
- especially useful for tuning architecture hyperparameters as well as standard hyperparams like learning rate etc.
- allows you to set up conditional search spaces where dependent structural configurations (e.g., matching head dimensions to total hidden width) are evaluated based on the performance of past trials.
Page Content
Eager search Spaces
Automated search for optimal hyperparameters using Python conditionals, loops, and syntax
Easy Parallelization
Parallelize hyperparameter searches over multiple threads or processes without modifying code
Code Examples
A simple optimization problem:
- Define
objectivefunction to be optimized. Let’s minimize(x - 2)^2 - Suggest hyperparameter values using
trialobject. Here, a float value ofxis suggested from-10to10 - Create a
studyobject and invoke theoptimizemethod over 100 trials
Python
Output
You can optimize PyTorch hyperparameters, such as the number of layers and the number of hidden nodes in each layer, in three steps:
- Wrap model training with an
objectivefunction and return accuracy - Suggest hyperparameters using a
trialobject - Create a
studyobject and execute the optimization
Python
Output
You can optimize Scikit-Learn hyperparameters, such as the C parameter of SVC and the max_depth of the RandomForestClassifier, in three steps:
- Wrap model training with an
objectivefunction and return accuracy - Suggest hyperparameters using a
trialobject - Create a
studyobject and execute the optimization
Python
Output