1

我正在使用 Optuna 进行 Hydra 框架的超参数搜索,但它抛出了这个错误:

    values = [float(ret.return_value)]
ValueError: Return value must be float-castable. Got 'None'.

这是什么意思?如何使返回值可浮动转换?

我的 config.yaml 看起来像这样:

hydra.sweeper.n_trials=30
    
    defaults:
      - override /hydra/sweeper: optuna
    
    # choose metric which will be optimized by Optuna
    optimized_metric: "val/best_dice"
    
    hydra:
      sweeper:
        _target_: hydra_plugins.hydra_optuna_sweeper.optuna_sweeper.OptunaSweeper
        storage: null
        study_name: learning_rate_optimizer
        n_jobs: 1
    
        # 'minimize' or 'maximize' the objective
        direction: maximize
    
        # number of experiments that will be executed
        n_trials: 20

        sampler:
          _target_: optuna.samplers.TPESampler
          seed: 42
          consider_prior: true
          prior_weight: 1.0
          consider_magic_clip: true
          consider_endpoints: false
          n_startup_trials: 10
          n_ei_candidates: 24
          multivariate: false
          warn_independent_sampling: true
    
        # define range of hyperparameters
        search_space:
          datamodule.batch_size:
            type: categorical
            choices: [8, 16, 32]
          model.lr:
            type: float
            low: 0.0001
            high: 0.2
4

0 回答 0