hyperas: Unable to run example code - TypeError('require string label')

Hi,

I am unable to run the first hyperas example. Specifically this line:

>>> model.add(Dropout({{uniform(0, 1)}}))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brohoro/Documents/PyProjects/envs/tensorflow/lib/python2.7/site-packages/hyperopt/pyll_utils.py", line 21, in wrapper
    raise TypeError('require string label')

The example without hyperas runs fine.

Here is my env

Python 2.7.13 Name: Keras Version: 2.0.4 Name: hyperas Version: 0.3 Name: hyperopt Version: 0.1

I have tried this both via Jupyter and via the python interpreter.

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

sorry to hear that. will look into the issue once back from vacation

Hi @maxpumperla , I am facing the same problem with uniform and choice. I tried installing hyperas from master i.e. hyperas 0.4 but I am still facing the same issue.

You can’t execute the model creation code directly in python. You need to wrap your code in a def create_model(...): ... function, and then call it from optim.minimize(model=create_model,... like in the example in the readme.

My understanding is that the reason for this is that hyperas works is by doing template replacement of everything in the {{...}} into a separate temporary file, and then running the model with the replaced braces.