autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 268 forks source link

AttributeError: '_thread._local' object has no attribute 'value' #410

Closed guiscaranse closed 5 years ago

guiscaranse commented 5 years ago

1) Confirm the below

2) Include the output of:

talos.__version__ = 0.6.3

3) Explain clearly what you expect to happen

ta.Restore should return a Talos/Keras model.

4) Explain what actually happened

I am getting this error after trying to restore and use a model using ta.Restore(model_path)

5) Provide a code-complete reference

My traceback contain all calls and further information is needed I can provide it.

Traceback (most recent call last):
  File "server.py", line 105, in get
    res = yield self.background_analyse(url)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "server.py", line 97, in background_analyse
    result = predict(i)
  File "/home/guiscaranse/Documentos/20-29 Pessoal/23 Repos/23.02 TCC/core/pales/controllers/BuilderController.py", line 28, in predict
    return keras.talos_model().model.predict_proba(translate_to_keras(url))[0]
  File "/home/guiscaranse/Documentos/20-29 Pessoal/23 Repos/23.02 TCC/core/pales/controllers/TalosController.py", line 75, in talos_model
    return ta.Restore(model_path)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/talos/commands/restore.py", line 48, in __init__
    self.model = load_model(self.file_prefix + '_model')
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/talos/utils/load_model.py", line 20, in load_model
    model = model_from_json(loaded_model_json)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/saving.py", line 661, in model_from_json
    return deserialize(config, custom_objects=custom_objects)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/layers/__init__.py", line 168, in deserialize
    printable_module_name='layer')
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 147, in deserialize_keras_object
    list(custom_objects.items())))
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/sequential.py", line 298, in from_config
    model = cls(name=name)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/sequential.py", line 88, in __init__
    super(Sequential, self).__init__(name=name)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/network.py", line 97, in __init__
    self._init_subclassed_network(**kwargs)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/network.py", line 304, in _init_subclassed_network
    self._base_init(name=name, **kwargs)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/network.py", line 111, in _base_init
    self.name = name
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/network.py", line 323, in __setattr__
    super(Network, self).__setattr__(name, value)
  File "/home/guiscaranse/.local/share/virtualenvs/core-vMLw6yVh/lib/python3.6/site-packages/keras/engine/base_layer.py", line 1215, in __setattr__
    if not _DISABLE_TRACKING.value:
AttributeError: '_thread._local' object has no attribute 'value'

github-actions[bot] commented 5 years ago

Welcome to Talos community! Thanks so much for creating your first issue :)

guiscaranse commented 5 years ago

This is a problem with Keras, sorry about that.

mikkokotila commented 5 years ago

@guiscaranse can you post the resolution / information you found in case other people end up with same.

guiscaranse commented 5 years ago

@mikkokotila right now there is no fix yet but a workaround could be downgrading tensorflow to 1.13.1 and Keras to 2.2.4, also using the 2.0 pre-release for tensorflow can make this work too.