maxpumperla / hyperas

Keras + Hyperopt: A very simple wrapper for convenient hyperparameter optimization
http://maxpumperla.com/hyperas/
MIT License
2.18k stars 318 forks source link

Why hyperas is executing Raw Text as code #287

Open DagonArises opened 2 years ago

DagonArises commented 2 years ago

I have encountered this issue where the hyper optimisation code tries to execute a block of raw text somewhere else in the notebook, raising a ridiculous Syntax Error. Sometimes it works sometimes it begins to execute markdown or raw text.

Even when I delete the raw text block the error message still points to that raw text, 'Potential issue:'. What's going on?

Traceback (most recent call last):

  File "/Users/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-13-7ea6376dc3f4>", line 38, in <module>
    eval_space= True, notebook_name= 'MotorIns')

  File "/Users/anaconda3/lib/python3.6/site-packages/hyperas/optim.py", line 69, in minimize
    keep_temp=keep_temp)

  File "/Users/anaconda3/lib/python3.6/site-packages/hyperas/optim.py", line 98, in base_minimizer
    model_str = get_hyperopt_model_string(model, data, functions, notebook_name, verbose, stack)

  File "/Users/anaconda3/lib/python3.6/site-packages/hyperas/optim.py", line 189, in get_hyperopt_model_string
    imports = extract_imports(cleaned_source, verbose)

  File "/Users/anaconda3/lib/python3.6/site-packages/hyperas/utils.py", line 40, in extract_imports
    tree = ast.parse(source)

  File "/Users/anaconda3/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)

  File "<unknown>", line 209
    Potential issue:
                  ^
SyntaxError: invalid syntax
DagonArises commented 2 years ago

I have deleted all the blocks in markdown and raw text. Exited the notebook, terminated the running command prompt and restarted the kernel. Then hyperas works without issue. Why is it not compatible with other languages in Jupytern notebook?