How to Grid Search Hyperparameters for Deep Learning Models in Python With Keras

Last Updated on August 27, 2020

Hyperparameter optimization is a big part of deep learning.

The reason is that neural networks are notoriously difficult to configure and there are a lot of parameters that need to be set. On top of that, individual models can be very slow to train.

In this post you will discover how you can use the grid search capability from the scikit-learn python machine learning library to tune the hyperparameters of Keras deep learning models.

After reading this post you will know:

  • How to wrap Keras models for use in scikit-learn and how to use grid search.
  • How to grid search common neural network parameters such as learning rate, dropout rate, epochs and number of neurons.
  • How to define your own hyperparameter tuning experiments on your own projects.

Kick-start your project with my new book Deep Learning With Python, including step-by-step tutorials and the Python source code files for all examples.

Let’s get started.

  • Update Nov/2016: Fixed minor issue in displaying grid search results in code examples.
  • Update Oct/2016: Updated examples for Keras 1.1.0, TensorFlow 0.10.0 and scikit-learn v0.18.
  • Update Mar/2017: Updated example for Keras 2.0.2, TensorFlow 1.0.1 and Theano 0.9.0.
  • Update
    To finish reading, please visit source site