Skip to main content

A Hyperparameter Tuning Library for Keras

Project description

KerasTuner

codecov PyPI version

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/

Quick links

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.

Quick introduction

Import KerasTuner and TensorFlow:

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.

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.

tuner = keras_tuner.RandomSearch(
    build_model,
    objective='val_loss',
    max_trials=5)

Start the search and get the best model:

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.

Contributing Guide

Please refer to the CONTRIBUTING.md for the contributing guide.

Thank all the contributors!

The contributors

Community

Ask your questions on our GitHub Discussions.

Citing KerasTuner

If KerasTuner helps your research, we appreciate your citations. Here is the BibTeX entry:

@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}}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keras-tuner-1.4.1.tar.gz (78.7 kB view details)

Uploaded Source

Built Distribution

keras_tuner-1.4.1-py3-none-any.whl (127.1 kB view details)

Uploaded Python 3

File details

Details for the file keras-tuner-1.4.1.tar.gz.

File metadata

  • Download URL: keras-tuner-1.4.1.tar.gz
  • Upload date:
  • Size: 78.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for keras-tuner-1.4.1.tar.gz
Algorithm Hash digest
SHA256 fd2076924eb7721405ea716109bab963d54b972db887a571f791bf692eb8f896
MD5 0effde63f161368b99d1dc068990cee5
BLAKE2b-256 e118523ba30bc37a40b9f9e2ce4235b0a92b3eefbaffd7858819d47d8c7efe98

See more details on using hashes here.

Provenance

File details

Details for the file keras_tuner-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: keras_tuner-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 127.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for keras_tuner-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e40b39144a23bad8a87365a28bd7c71a6c14313a7e6f8541dd34cdaf86f4b6d
MD5 d4998d1803f0ed63e52743f1d040f99b
BLAKE2b-256 ba86914f0cf69d0131f78a0658086a959270bd3d6a5f74009145293aa880674d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page