我试图使用Hyperas来调优参数,但我无法解释有关它的一些细节。
Q1) max_eval参数在optim.minimize中是做什么的?
( Q2)它是否对每个max_eval进行了每一个参数的组合,并根据最佳参数给出了最好的损失?
Q3)如果我给出max_eval = 5怎么办?
Q4)完成所有max_evals后,best_run和best_model返回什么?
( Q5)在模型函数下面,我将损失作为-test_acc返回,这与调优参数有什么关系,为什么我们在那里使用负号?
def model(x_train, y_train, x_test, y_test):
dense_units1 = {{choice([64, 126, 256, 512])}}
activations = {{choice(['relu', 'sigmoid'])}}
epochs = 100
verbose = 0
model = Sequential([
# layer 1
Dense(dense_units1, activations, input_shape=(784,)),
....
....
....
])
# compiling model
model.compile(optimizers, loss='categorical_crossentropy', metrics=['accuracy'])
# fitting the model
result = model.fit(x_train, y_train, validation_split=0.2, batch_size=batch_size,
epochs=epochs, verbose=verbose, callbacks=[ES, MC])
test_loss, test_acc = model.evaluate(x_test, y_test, batch_size=512)
return {'loss': -test_acc, 'status': STATUS_OK, 'model': model}
best_run, best_model = optim.minimize(model=model, data=dataset, algo=tpe.suggest,
max_evals=5,
trials=Trials(), notebook_name='MNIST',
verbose=True)发布于 2019-07-19 18:43:17
max_eval参数只是优化运行的最大次数。(例如,如果max_evals = 5,Hyperas将选择一个不同的超参数组合5次,并根据您选择的时间数运行每个组合)max_eval都要经过一个超参数的组合。超参数的最佳组合是在完成max_eval参数中的所有评估之后。best_model和best_run将返回相同的内容。您应该将其添加到代码中:
打印(“最佳性能模型选择的超参数:”)打印(Best_run)
这将从它所做的所有运行中打印出最好的超级参数。https://stackoverflow.com/questions/56745518
复制相似问题