Skip to content

TypeError: 'NoneType' object is not subscriptable self._space.max() #502

@james-imi

Description

@james-imi

I am receiving this error whenever the init_points are fulfilled.

  File "/home/workspace/xray-classifier/train_impaction_opt.py", line 538, in train_opt
    optimizer.maximize(
  File "/home/anaconda3/envs/xray_classifier/lib/python3.10/site-packages/bayes_opt/bayesian_optimization.py", line 372, in maximize
    x_probe = self.suggest(util)
  File "/home/anaconda3/envs/xray_classifier/lib/python3.10/site-packages/bayes_opt/bayesian_optimization.py", line 276, in suggest
    y_max_params=self._space.params_to_array(self._space.max()['params']))
TypeError: 'NoneType' object is not subscriptable

with these constraits


# Define the function to optimize
pbounds = {
    "lr": (1e-3, 1e-4 / 8),
    'weight_decay': (0.01, 0.0001),
    'freeze': (0, 6),
    # Focal loss gamma and alpha
    'gamma': (0.5, 5),
    'alpha': (0.1, 0.9)
}

I printed the values and it shows this

self._gp: GaussianProcessRegressor(alpha=1e-06, kernel=Matern(length_scale=1, nu=2.5),
                         n_restarts_optimizer=5, normalize_y=True,
                         random_state=RandomState(MT19937) at 0x71EBCD6B6D40)
self.constraint: None
self._space._target_max(): None
self._space.bounds: [[1.00e-01 9.00e-01]
 [0.00e+00 6.00e+00]
 [5.00e-01 5.00e+00]
 [1.00e-03 1.25e-05]
 [1.00e-02 1.00e-04]]
Traceback (most recent call last):
  File "/home/anaconda3/envs/xray_classifier/lib/python3.10/site-packages/bayes_opt/bayesian_optimization.py", line 381, in maximize
    x_probe = next(self._queue)
  File "/home/anaconda3/envs/xray_classifier/lib/python3.10/site-packages/bayes_opt/bayesian_optimization.py", line 40, in __next__
    raise StopIteration("Queue is empty, no more objects to retrieve.")
StopIteration: Queue is empty, no more objects to retrieve.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions