Keras Hypermodel -使用默认参数构建



我用KerasTuner实现了超参数调优。我希望有跳过超参数调优并使用默认值的选项。

现在看起来是这样的(它在搜索后使用最佳参数构建模型)

MyHyperModel(HyperModel)
def build(self, hp)
...hp.choice('hyperparameter', [1,2,3], default=3)
return model
tuner = HyperBand(
MyHyperModel(),
...
)
tuner.search(
train_inputs,
train_targets,
...
)
best_hp = tuner.get_best_hyperparameters()[0]
model = tuner.hypermodel.build(best_hp)

我想要一些像

default_model = tuner.hypermodel.build(use_default_parameter=True)

返回具有超参数默认值的Keras模型,然后可以进行训练。但是我想不明白。

使用空的HyperParameters容器作为参数调用构建函数,返回带有默认参数的模型:

hypermodel = MyHyperModel()
hp = kt.HyperParameters()
model = hypermodel.build(hp)

最新更新