HunterMcGushion / hyperparameter_hunter

Easy hyperparameter optimization and automatic result saving across machine learning algorithms and libraries
MIT License
704 stars 100 forks source link

Metaclass conflict with Keras 2.3.0 #199

Open HunterMcGushion opened 4 years ago

HunterMcGushion commented 4 years ago

Error Traceback

Bug Hunt Notes

OverLordGoldDragon commented 4 years ago

Subclassing ArgumentTracer(abc.ABCMeta) in hyperparameter_hunter.tracers.py, then applying the following fixes yields the error shown toward bottom -- also shown output for print(self.name) inserted right above the breaking code.


# keras_helper.py
# AttributeError: 'LossFunctionWrapper' object has no attribute '__name__'
try:
    compile_params["loss_function_names"] = [_.__name__ for _ in compile_params["loss_functions"]]
except:
    compile_params["loss_function_names"] = [_.name for _ in compile_params["loss_functions"]]

# AttributeError: 'Sequential' object has no attribute 'weighted_metrics'
try:
    compile_params["weighted_metrics"] = get_keras_attr(model, "weighted_metrics")
except:
    print('WARNING: could not fetch "weighted_metrics" attribute; skipping...')

Full error trace:

total:0 # print(self.name) outputs
count:0
UnreadVariable

Traceback (most recent call last):

  File "<ipython-input-1-1226ec5313a7>", line 56, in <module>
    execute()
  File "<ipython-input-1-1226ec5313a7>", line 49, in execute
    shuffle=True,
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiment_core.py", line 165, in __call__
    return super().__call__(*args, **kwargs)
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiments.py", line 749, in __init__
    target_metric=target_metric,
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiments.py", line 595, in __init__
    target_metric=target_metric,
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiments.py", line 302, in __init__
    self.preparation_workflow()
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiments.py", line 354, in preparation_workflow
    self._generate_hyperparameter_key()
  File "C:\hyperparameter_hunter\hyperparameter_hunter\experiments.py", line 450, in _generate_hyperparameter_key
    self.hyperparameter_key = HyperparameterKeyMaker(parameters, self.cross_experiment_key)
  File "C:\hyperparameter_hunter\hyperparameter_hunter\keys\makers.py", line 367, in __init__
    KeyMaker.__init__(self, parameters, **kwargs)
  File "C:\hyperparameter_hunter\hyperparameter_hunter\keys\makers.py", line 90, in __init__
    self.parameters = deepcopy(parameters)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 215, in _deepcopy_list
    append(deepcopy(a, memo))
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 215, in _deepcopy_list
    append(deepcopy(a, memo))
  File "D:\Anaconda\envs\test_hh\lib\copy.py", line 161, in deepcopy
    y = copier(memo)
  File "D:\Anaconda\envs\test_hh\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py", line 464, in __deepcopy__
    name=self._shared_name + "_copy",
  File "D:\Anaconda\envs\test_hh\lib\site-packages\tensorflow_core\python\ops\variables.py", line 1155, in _shared_name
    return self.name[:self.name.index(":")]

ValueError: substring not found