Keras: Out of memory when doing hyper parameter grid search

后端 未结 2 847
甜味超标
甜味超标 2020-12-28 18:58

I\'m running multiple nested loops to do hyper parameter grid search. Each nested loop runs through a list of hyper parameter values and inside the innermost loop, a Keras s

2条回答
  •  醉梦人生
    2020-12-28 19:19

    As indicated, the backend being used is Tensorflow. With the Tensorflow backend the current model is not destroyed, so you need to clear the session.

    After the usage of the model just put:

    if K.backend() == 'tensorflow':
        K.clear_session()
    

    Include the backend:

    from keras import backend as K
    

    Also you can use sklearn wrapper to do grid search. Check this example: here. Also for more advanced hyperparameter search you can use hyperas.

提交回复
热议问题