# KerasTuner
[![](https://github.com/keras-team/keras-tuner/workflows/Tests/badge.svg?branch=master)](https://github.com/keras-team/keras-tuner/actions?query=workflow%3ATests+branch%3Amaster)
[![codecov](https://codecov.io/gh/keras-team/keras-tuner/branch/master/graph/badge.svg)](https://codecov.io/gh/keras-team/keras-tuner)
[![PyPI version](https://badge.fury.io/py/keras-tuner.svg)](https://badge.fury.io/py/keras-tuner)
KerasTuner is an easy-to-use, scalable hyperparameter optimization framework
that solves the pain points of hyperparameter search. Easily configure your
search space with a define-by-run syntax, then leverage one of the available
search algorithms to find the best hyperparameter values for your models.
KerasTuner comes with Bayesian Optimization, Hyperband, and Random Search algorithms
built-in, and is also designed to be easy for researchers to extend in order to
experiment with new search algorithms.
Official Website: [https://keras.io/keras_tuner/](https://keras.io/keras_tuner/)
## Quick links
* [Getting started with KerasTuner](https://keras.io/guides/keras_tuner/getting_started)
* [KerasTuner developer guides](https://keras.io/guides/keras_tuner/)
* [KerasTuner API reference](https://keras.io/api/keras_tuner/)
## Installation
KerasTuner requires **Python 3.8+** and **TensorFlow 2.0+**.
Install the latest release:
```
pip install keras-tuner
```
You can also check out other versions in our
[GitHub repository](https://github.com/keras-team/keras-tuner).
## Quick introduction
Import KerasTuner and TensorFlow:
```python
import keras_tuner
from tensorflow import keras
```
Write a function that creates and returns a Keras model.
Use the `hp` argument to define the hyperparameters during model creation.
```python
def build_model(hp):
model = keras.Sequential()
model.add(keras.layers.Dense(
hp.Choice('units', [8, 16, 32]),
activation='relu'))
model.add(keras.layers.Dense(1, activation='relu'))
model.compile(loss='mse')
return model
```
Initialize a tuner (here, `RandomSearch`).
We use `objective` to specify the objective to select the best models,
and we use `max_trials` to specify the number of different models to try.
```python
tuner = keras_tuner.RandomSearch(
build_model,
objective='val_loss',
max_trials=5)
```
Start the search and get the best model:
```python
tuner.search(x_train, y_train, epochs=5, validation_data=(x_val, y_val))
best_model = tuner.get_best_models()[0]
```
To learn more about KerasTuner, check out [this starter guide](https://keras.io/guides/keras_tuner/getting_started/).
## Contributing Guide
Please refer to the [CONTRIBUTING.md](https://github.com/keras-team/keras-tuner/blob/master/CONTRIBUTING.md) for the contributing guide.
Thank all the contributors!
[![The contributors](https://raw.githubusercontent.com/keras-team/keras-tuner/master/docs/contributors.svg)](https://github.com/keras-team/keras-tuner/graphs/contributors)
## Community
Ask your questions on our [GitHub Discussions](https://github.com/keras-team/keras-tuner/discussions).
## Citing KerasTuner
If KerasTuner helps your research, we appreciate your citations.
Here is the BibTeX entry:
```bibtex
@misc{omalley2019kerastuner,
title = {KerasTuner},
author = {O'Malley, Tom and Bursztein, Elie and Long, James and Chollet, Fran\c{c}ois and Jin, Haifeng and Invernizzi, Luca and others},
year = 2019,
howpublished = {\url{https://github.com/keras-team/keras-tuner}}
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/keras-team/keras-tuner",
"name": "keras-tuner",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "The KerasTuner authors",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/f4/0f/c59cd351558ef679db7d3fc04327a8a25f03d98a64fc97ab631e0cf9f0e5/keras-tuner-1.4.7.tar.gz",
"platform": null,
"description": "# KerasTuner\n\n[![](https://github.com/keras-team/keras-tuner/workflows/Tests/badge.svg?branch=master)](https://github.com/keras-team/keras-tuner/actions?query=workflow%3ATests+branch%3Amaster)\n[![codecov](https://codecov.io/gh/keras-team/keras-tuner/branch/master/graph/badge.svg)](https://codecov.io/gh/keras-team/keras-tuner)\n[![PyPI version](https://badge.fury.io/py/keras-tuner.svg)](https://badge.fury.io/py/keras-tuner)\n\nKerasTuner is an easy-to-use, scalable hyperparameter optimization framework\nthat solves the pain points of hyperparameter search. Easily configure your\nsearch space with a define-by-run syntax, then leverage one of the available\nsearch algorithms to find the best hyperparameter values for your models.\nKerasTuner comes with Bayesian Optimization, Hyperband, and Random Search algorithms\nbuilt-in, and is also designed to be easy for researchers to extend in order to\nexperiment with new search algorithms.\n\nOfficial Website: [https://keras.io/keras_tuner/](https://keras.io/keras_tuner/)\n\n## Quick links\n\n* [Getting started with KerasTuner](https://keras.io/guides/keras_tuner/getting_started)\n* [KerasTuner developer guides](https://keras.io/guides/keras_tuner/)\n* [KerasTuner API reference](https://keras.io/api/keras_tuner/)\n\n\n## Installation\n\nKerasTuner requires **Python 3.8+** and **TensorFlow 2.0+**.\n\nInstall the latest release:\n\n```\npip install keras-tuner\n```\n\nYou can also check out other versions in our\n[GitHub repository](https://github.com/keras-team/keras-tuner).\n\n\n## Quick introduction\n\nImport KerasTuner and TensorFlow:\n\n```python\nimport keras_tuner\nfrom tensorflow import keras\n```\n\nWrite a function that creates and returns a Keras model.\nUse the `hp` argument to define the hyperparameters during model creation.\n\n```python\ndef build_model(hp):\n model = keras.Sequential()\n model.add(keras.layers.Dense(\n hp.Choice('units', [8, 16, 32]),\n activation='relu'))\n model.add(keras.layers.Dense(1, activation='relu'))\n model.compile(loss='mse')\n return model\n```\n\nInitialize a tuner (here, `RandomSearch`).\nWe use `objective` to specify the objective to select the best models,\nand we use `max_trials` to specify the number of different models to try.\n\n```python\ntuner = keras_tuner.RandomSearch(\n build_model,\n objective='val_loss',\n max_trials=5)\n```\n\nStart the search and get the best model:\n\n```python\ntuner.search(x_train, y_train, epochs=5, validation_data=(x_val, y_val))\nbest_model = tuner.get_best_models()[0]\n```\n\nTo learn more about KerasTuner, check out [this starter guide](https://keras.io/guides/keras_tuner/getting_started/).\n\n## Contributing Guide\n\nPlease refer to the [CONTRIBUTING.md](https://github.com/keras-team/keras-tuner/blob/master/CONTRIBUTING.md) for the contributing guide.\n\nThank all the contributors!\n\n[![The contributors](https://raw.githubusercontent.com/keras-team/keras-tuner/master/docs/contributors.svg)](https://github.com/keras-team/keras-tuner/graphs/contributors)\n\n## Community\n\nAsk your questions on our [GitHub Discussions](https://github.com/keras-team/keras-tuner/discussions).\n\n## Citing KerasTuner\n\nIf KerasTuner helps your research, we appreciate your citations.\nHere is the BibTeX entry:\n\n```bibtex\n@misc{omalley2019kerastuner,\n\ttitle = {KerasTuner},\n\tauthor = {O'Malley, Tom and Bursztein, Elie and Long, James and Chollet, Fran\\c{c}ois and Jin, Haifeng and Invernizzi, Luca and others},\n\tyear = 2019,\n\thowpublished = {\\url{https://github.com/keras-team/keras-tuner}}\n}\n```\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "A Hyperparameter Tuning Library for Keras",
"version": "1.4.7",
"project_urls": {
"Homepage": "https://github.com/keras-team/keras-tuner"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "db5d945296512980b0827e93418514c8be9236baa6f0a1e8ca8be3a2026665b0",
"md5": "255781058ad30a2fd75490ee47cb2da7",
"sha256": "0bcf0220eccc74e7a6a9bd7c8e58531a1af8515019e6bc2dc495833155c07fe2"
},
"downloads": -1,
"filename": "keras_tuner-1.4.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "255781058ad30a2fd75490ee47cb2da7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 129147,
"upload_time": "2024-03-04T19:41:39",
"upload_time_iso_8601": "2024-03-04T19:41:39.607209Z",
"url": "https://files.pythonhosted.org/packages/db/5d/945296512980b0827e93418514c8be9236baa6f0a1e8ca8be3a2026665b0/keras_tuner-1.4.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f40fc59cd351558ef679db7d3fc04327a8a25f03d98a64fc97ab631e0cf9f0e5",
"md5": "dc649941609d595675be30b6f40e653e",
"sha256": "6befd25ee81476e6207d8ca7ed7dc674b8194437cfa0b127294cd00da905ff22"
},
"downloads": -1,
"filename": "keras-tuner-1.4.7.tar.gz",
"has_sig": false,
"md5_digest": "dc649941609d595675be30b6f40e653e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 79915,
"upload_time": "2024-03-04T19:41:41",
"upload_time_iso_8601": "2024-03-04T19:41:41.722041Z",
"url": "https://files.pythonhosted.org/packages/f4/0f/c59cd351558ef679db7d3fc04327a8a25f03d98a64fc97ab631e0cf9f0e5/keras-tuner-1.4.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-04 19:41:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "keras-team",
"github_project": "keras-tuner",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "keras-tuner"
}