- Notifications
You must be signed in to change notification settings - Fork46
A Bayesian optimization toolbox built on TensorFlow
License
secondmind-labs/trieste
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Documentation (develop) |Documentation (release) |Tutorials |API reference |
Trieste (pronounced tree-est) is a Bayesian optimization toolbox built onTensorFlow. Trieste is named after the bathyscapheTrieste, the first vehicle to take a crew to Challenger Deep in the Mariana Trench, the lowest point on the Earth’s surface: the literal global minimum.
Why Trieste?
- Highly modular design and easily customizable. Extend it with your custom model or acquisition functions. Ideal for practitioners that want to use it in their systems or for researchers wishing to implement their latest ideas.
- Seamless integration with TensorFlow. Leveraging fully its auto differentiation - no more writing of gradients for your acquisition functions!, and scalability capabilities via its support for highly parallelized modern hardware (e.g. GPUs).
- General purpose toolbox. Advanced algorithms covering all corners of Bayesian optimization and Active learning - batch, asynchronous, constraints, multi-fidelity, multi-objective - you name it, Trieste has it.
- Versatile model support out-of-the-box. From gold-standard Gaussian processes (GPs;GPflow) to alternatives like sparse variational GPs, Deep GPs (GPflux) or Deep Ensembles (Keras), that scale much better with the number of function evaluations.
- Real-world oriented. Our Ask-Tell interface allows users to apply Bayesian optimization across a range of non-standard real-world settings where control over black-box function is partial. Built on TensorFlow and with comprehensive testing Trieste is production-ready.
Here's a quick overview of the main components of a Bayesian optimization loop. For more details, see ourDocumentation where we have multipleTutorials covering both the basic functionalities of the toolbox, as well as more advanced usage.
Let's set up a synthetic black-box objective function we wish to minimize, for example, a popular Branin optimization function, and generate some initial data
fromtrieste.objectivesimportBranin,mk_observerobserver=mk_observer(Branin.objective)initial_query_points=Branin.search_space.sample(5)initial_data=observer(initial_query_points)
First step is to create a probabilistic model of the objective function, for example a Gaussian Process model
fromtrieste.models.gpflowimportbuild_gpr,GaussianProcessRegressiongpflow_model=build_gpr(initial_data,Branin.search_space)model=GaussianProcessRegression(gpflow_model)
Next ingredient is to choose an acquisition rule and acquisition function
fromtrieste.acquisitionimportEfficientGlobalOptimization,ExpectedImprovementacquisition_rule=EfficientGlobalOptimization(ExpectedImprovement())
Finally, we optimize the acquisition function using our model for a number of steps and we check the obtained minimum
fromtrieste.bayesian_optimizerimportBayesianOptimizerbo=BayesianOptimizer(observer,Branin.search_space)num_steps=15result=bo.optimize(num_steps,initial_data,model)query_point,observation,arg_min_idx=result.try_get_optimal_point()
Trieste supports Python 3.9+ and TensorFlow 2.5+, and usessemantic versioning.
To install the latest (stable) release of the toolbox fromPyPI, usepip
:
$ pip install trieste
or to install from sources, run
$ pip install.
in the repository root.
To install this project in editable mode, run the commands below from the root directory of thetrieste
repository.
git clone https://github.com/secondmind-labs/trieste.gitcd triestepip install -e.
For installation to be able to run quality checks, as well as other details, seethe guidelines for contributors.
Trieste has adocumentation site with tutorials on how to use the library, and an API reference. You can also run the tutorials interactively. They can be found in the notebooks directory, and are written as Python scripts for running with Jupytext. To run them, first install trieste from sources as above, then install additional dependencies with
$ pip install -r notebooks/requirements.txt
Finally, run the notebooks with
$ jupyter-notebook notebooks
Alternatively, you can copy and paste the tutorials into fresh notebooks and avoid installing the library from source. To ensure you have the required plotting dependencies, simply run:
$ pip install trieste[plotting]
Liketensorflow-probability, Trieste currently uses Keras 2. When using Tensorflow versions 2.16 onwards (which default to Keras 3) this needs to be imported fromtf_keras
rather thantf.keras
. Alternatively, for a shortcut that works with all versions of Tensorflow, you can write:
fromgpflow.kerasimporttf_keras
Bugs, feature requests, pain points, annoying design quirks, etc:Please useGitHub issues to flag up bugs/issues/pain points, suggest new features, and discuss anything else related to the use of Trieste that in some sense involves changing the Trieste code itself. We positively welcome comments or concerns about usability, and suggestions for changes at any level of design. We aim to respond to issues promptly, but if you believe we may have forgotten about an issue, please feel free to add another comment to remind us.
We have a publicSecondmind Labs slack workspace. Please use thisinvite link and join the #trieste channel, whether you'd just like to ask short informal questions or want to be involved in the discussion and future development of Trieste.
All constructive input is very much welcome. For detailed information, seethe guidelines for contributors.
To cite Trieste, please reference ourarXiv paper where we review the framework and describe the design. Sample Bibtex is given below:
@misc{trieste2023, author = {Picheny, Victor and Berkeley, Joel and Moss, Henry B. and Stojic, Hrvoje and Granta, Uri and Ober, Sebastian W. and Artemev, Artem and Ghani, Khurram and Goodall, Alexander and Paleyes, Andrei and Vakili, Sattar and Pascual-Diaz, Sergio and Markou, Stratis and Qing, Jixiang and Loka, Nasrulloh R. B. S and Couckuyt, Ivo and Morter, Chris}, title = {Trieste: Efficiently Exploring The Depths of Black-box Functions with TensorFlow}, publisher = {arXiv}, year = {2023}, doi = {10.48550/ARXIV.2302.08436}, url = {https://arxiv.org/abs/2302.08436}}
About
A Bayesian optimization toolbox built on TensorFlow