Polaris is a hyperparamter optimization library.
We plan to support every state-of-art tuning method as follows.
- Random Search
- Bayesian Optimization
- Tree-structured Parzen Estimators (TPE)
Polaris' documentation can be found at https://polaris.readthedocs.io/
- Python >= 3.6
- RabbitMQ (Only for parallel execution)
$ pip install polaris-py
from polaris import Polaris, STATUS_SUCCESS, Trials, Bounds
def pseudo_train(params, exp_info):
lr_squared = (params['lr'] - 0.006) ** 2
weight_decay_squared = (params['weight_decay'] - 0.02) ** 2
loss = lr_squared + weight_decay_squared
return {
'loss': loss,
'status': STATUS_SUCCESS,
}
if __name__ == '__main__':
bounds = [
Bounds('lr', 0.001, 0.01),
Bounds('weight_decay', 0.0002, 0.04),
]
trials = Trials()
polaris = Polaris(
pseudo_train, bounds, 'bayesian_opt',
trials, max_evals=100, exp_key='this_is_test')
best_params = polaris.run()
print(best_params)
- Run
rabbitmq-server
- Set
RABBITMQ_URL
(ampq://guest:guest@localhost//) - Run
polaris-worker --exp-key this_is_test
- Run codes as follows
- Run
rabbitmq-server
- Set
RABBITMQ_URL
(ampq://guest:guest@localhost//) - Run
mpirun -n 4 polaris-worker --mpi --exp-key this_is_test
- Run codes as follows
...
if __name__ == '__main__':
bounds = [
Bounds('lr', 0.001, 0.01),
Bounds('weight_decay', 0.0002, 0.04),
]
trials = Trials()
polaris = Polaris(
pseudo_train, bounds, 'bayesian_opt',
trials, max_evals=100, exp_key='this_is_test')
best_params = polaris.run_parallel()
print(best_params)