Skip to content

Metaclass conflict with Keras 2.3.0 #199

@HunterMcGushion

Description

@HunterMcGushion
  • Using HyperparameterHunter with the recently released Keras version 2.3.0 raises metaclass conflict error, breaking Keras compatibility
  • TEMPORARY WORKAROUND: Use Keras 2.2.5

Error Traceback

  • From executing examples/keras_examples/experiment_example.py
Traceback (most recent call last):
  File "keras_examples/experiment_example.py", line 1, in <module>
    from hyperparameter_hunter import Environment, CVExperiment
  File "/Users/Hunter/hyperparameter_hunter/hyperparameter_hunter/__init__.py", line 29, in <module>
    from .environment import Environment
  File "/Users/Hunter/hyperparameter_hunter/hyperparameter_hunter/environment.py", line 27, in <module>
    from hyperparameter_hunter.keys.makers import CrossExperimentKeyMaker
  File "/Users/Hunter/hyperparameter_hunter/hyperparameter_hunter/keys/makers.py", line 28, in <module>
    from hyperparameter_hunter.library_helpers.keras_optimization_helper import initialize_dummy_model
  File "/Users/Hunter/hyperparameter_hunter/hyperparameter_hunter/library_helpers/keras_optimization_helper.py", line 52, in <module>
    from keras.callbacks import Callback as base_keras_callback
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/utils/__init__.py", line 26, in <module>
    from .vis_utils import model_to_dot
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/utils/vis_utils.py", line 7, in <module>
    from ..models import Model
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/models.py", line 10, in <module>
    from .engine.input_layer import Input
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/engine/__init__.py", line 8, in <module>
    from .training import Model
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/engine/training.py", line 14, in <module>
    from . import training_utils
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/engine/training_utils.py", line 17, in <module>
    from .. import metrics as metrics_module
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/keras/metrics.py", line 34, in <module>
    class Metric(Layer):
  File "/Users/Hunter/hyperparameter_hunter/env/lib/python3.7/site-packages/six.py", line 849, in wrapper
    return metaclass(cls.__name__, cls.__bases__, orig_vars)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/abc.py", line 126, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Bug Hunt Notes

  • Updating tracers.ArgumentTracer to descend from ABCMeta does resolve the metaclass conflict, but leads to different errors regarding the usage of __deepcopy__ in TensorFlow:
    • NotImplementedError: __deepcopy__() is only available when eager execution is enabled.
  • Further changes to the Keras API cause some unrelated tests to fail
  • Noteworthy changes in Keras 2.3.0 that will require HH fixes:
    • Introduced class-based losses
    • Introduced class-based metrics
    • Renamed lr to learning_rate for all optimizers
    • Deprecated decay argument for all optimizers
    • Changed how metric names are reported to use the exact string given by the user ("acc" vs. "accuracy")

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions