我正在使用 Keras 来调整模型的超参数。搜索过程很顺利,但是,当我使用“tuner.results_summary()”或“tuner.oracle.get_best_trials(num_trials=1)[0]”查看得分最高的轨迹时,我发现了一些奇怪的东西。如果我运行“tuner.results_summary()”几次,搜索结束时,前 10 个试验是不同的。这是为什么?
project_name='InputNormN2_1'
Batch_size=128
h_tuner = Hyperband(
build_model,
max_epochs=81,
factor=3,
objective=kt.Objective("val_root_mean_squared_error", direction="min"),
executions_per_trial=1,
directory='Paper_Results',
project_name=project_name)
stop_early = tf.keras.callbacks.EarlyStopping(monitor='val_root_mean_squared_error', patience=50)
h_tuner.search(x=x_train,y=y_train,validation_data=(x_val, y_val),
batch_size=Batch_size,
shuffle=True,
callbacks=[stop_early])
如果我再次加载调谐器并查看结果摘要:
h_tuner = Hyperband(
build_model,
max_epochs=81,
factor=3,
objective=kt.Objective("val_root_mean_squared_error", direction="min"),
executions_per_trial=1,
directory='Paper_Results',
project_name=project_name)
print(h_tuner.results_summary())
Trial_n=h_tuner.oracle.get_best_trials(num_trials=1)[0].hyperparameters.values
print(Trial_n)