我想将RandomizedSearchCV(或GridSearchCV)应用到我的Keras模型(TensorFlow后端)。但是,经过多次不同超参数集的训练,出现了OOM错误。在
下面是我的代码和错误消息。我怎么解决这个问题?提前谢谢。在def build_model(num_filters = 10,
num_classes = 6,
sequence_max_length=512,
vocab_size=71,
embedding_size=16,
learning_rate=0.001,
dropout = 0.2,
top_k=3,
embedding_matrix = None,
model_path=None):
... do something
return model
keras_model = KerasClassifier(build_fn=build_model,
embedding_matrix = embedding_matrix)
random_search_model = RandomizedSearchCV(keras_model,
n_iter = 5,
param_distributions = hparm_dist,
refit = True,
n_jobs = 1)
错误消息:
^{pr2}$
更新:
通过添加keras.backend.clear\u会话()结束sklearn.cross_验证。符合并得分。在