【问题标题】:Keras Hypermodel - build with default parametersKeras Hypermodel - 使用默认参数构建
【发布时间】:2021-09-07 12:49:34
【问题描述】:

我使用 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 模型,然后可以进行训练。 但我想不通。

【问题讨论】:

    标签: keras keras-tuner


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多