Kahn8sa
Kahn8sa

Reputation: 19

Optuna, ValueError: Return value must be float-castable. Got 'None'

I am using Optuna for hyperparameter search with Hydra framework, but it throws me this error:

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

What does it mean? How do I make return value float-castable?

My config.yaml looks like this:

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

Upvotes: 1

Views: 514

Answers (0)

Related Questions