# Error when setting up bayesian optimizer with asha scheduler

**URL:** <https://discuss.ray.io/t/error-when-setting-up-bayesian-optimizer-with-asha-scheduler/3807>\
**Category:** Ray Tune\
**Created:** [October 14, 2021, 2:06am UTC](https://discuss.ray.io/t/error-when-setting-up-bayesian-optimizer-with-asha-scheduler/3807 "2021-10-14T02:06:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry\_lei](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/henry_lei/32/1613_2.png) [@henry\_lei](https://discuss.ray.io/u/henry_lei)\
**Post date:** [October 14, 2021, 2:06am UTC](https://discuss.ray.io/t/error-when-setting-up-bayesian-optimizer-with-asha-scheduler/3807/1 "2021-10-14T02:06:15Z")

</div>

I’m getting type errors when trying to set up a bayesian optimizer and asha scheduler for hyperparameter tuning with RLlib.

relevant code:

# Bayesian optimizer for hyperparameters

search\_alg = BayesOptSearch(metric=“mean\_loss”, mode=“min”)  
bayesopt = ConcurrencyLimiter(search\_alg, max\_concurrent=2)

# Asha Scheduler

asha\_scheduler = ASHAScheduler(  
time\_attr=‘training\_iteration’,  
metric=‘episode\_reward\_mean’,  
mode=‘max’,  
max\_t=100,  
grace\_period=10,  
reduction\_factor=3,  
brackets=1)

# run experiment

ray.init()  
analysis = tune.run(ppo.PPOTrainer, config=config, stop=stop\_dict, local\_dir=output\_dir,  
checkpoint\_freq=checkpoint\_freq, checkpoint\_at\_end=True, name=expr\_name, scheduler=asha\_scheduler, search\_alg=bayesopt)  
print("Best hyperparameters found were: ", analysis.best\_config)

This is the relevant error I think, it’s not letting me copy the full traceback.

TypeError: Failed to convert object of type \<class ‘ray.tune.sample.Float’\> to Tensor. Contents: \<ray.tune.sample.Float object at 0x7fc45de98210\>. Consider casting elements to a supported type.

python 3.7.10  
ray 1.5.2  
tensorflow 2.6

---

<div class="post-metadata">

**Author:** ![kai](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kai/32/3380_2.png) [@kai](https://discuss.ray.io/u/kai)\
**Post date:** [October 18, 2021, 11:35am UTC](https://discuss.ray.io/t/error-when-setting-up-bayesian-optimizer-with-asha-scheduler/3807/2 "2021-10-18T11:35:44Z")

</div>

Can you post your `config` dict? The error message indicates a misconfiguration of the search space/config parameters.
