1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Deep Learning with Keras

Exercise

Tuning the model parameters

It's time to try out different parameters on your model and see how well it performs!

The create_model() function you built in the previous exercise is ready for you to use.

Since fitting the RandomizedSearchCV object would take too long, the results you'd get are printed in the show_results() function. You could try random_search.fit(X,y) in the console yourself to check it does work after you have built everything else, but you will probably timeout the exercise (so copy your code first if you try this or you can lose your progress!).

You don't need to use the optional epochs and batch_size parameters when building your KerasClassifier object since you are passing them as params to the random search and this works already.

Instructions

100 XP
  • Import KerasClassifier from tensorflow.keras scikit_learn wrappers.
  • Use your create_model function when instantiating your KerasClassifier.
  • Set 'relu' and 'tanh' as activation, 32, 128, and 256 as batch_size, 50, 100, and 200 epochs, and learning_rate of 0.1, 0.01, and 0.001.
  • Pass your converted model and the chosen params as you build your RandomizedSearchCV object.