autokeras
autokeras copied to clipboard
Broken hyperopts in RNN block (upd: affects all blocks, has workarounnd)
Bug Description
I'm having troubles shitching autokeras
from 1.0.12
to 1.0.15
- hyperparmas for blocks are broken.
Bug Reproduction
Code for reproducing the bug:
input_node = ak.Input()
prf_regressor = input_node
prf_regressor = ak.RNNBlock(
return_sequences=False, bidirectional=False)(prf_regressor)
prf_regressor = ak.RegressionHead()(prf_regressor)
and just add to any automodel.
on version 1.0.12
everything worked perfectly. and on 1.0.15
i'm constantly receiving this error:
Traceback (most recent call last):
File "predictor.py", line 274, in <module>
run_train(config)
File "predictor.py", line 196, in run_train
model = ak.AutoModel(
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/auto_model.py", line 142, in __init__
self.tuner = tuner(
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/tuners/greedy.py", line 230, in __init__
super().__init__(oracle=oracle, hypermodel=hypermodel, **kwargs)
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/engine/tuner.py", line 54, in __init__
self.hypermodel.hypermodel.save(os.path.join(self.project_dir, "graph"))
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/graph.py", line 331, in save
io_utils.save_json(filepath, self.get_config())
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/graph.py", line 188, in get_config
blocks = [blocks_module.serialize(block) for block in self.blocks]
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/graph.py", line 188, in <listcomp>
blocks = [blocks_module.serialize(block) for block in self.blocks]
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/blocks/__init__.py", line 46, in serialize
return tf.keras.utils.serialize_keras_object(obj)
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 503, in serialize_keras_object
config = instance.get_config()
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/autokeras/blocks/basic.py", line 192, in get_config
"bidirectional": hyperparameters.serialize(self.bidirectional),
File "/home/administrator/anaconda3/envs/libra2/lib/python3.8/site-packages/keras_tuner/engine/hyperparameters.py", line 1077, in serialize
return {"class_name": obj.__class__.__name__, "config": obj.get_config()}
AttributeError: 'bool' object has no attribute 'get_config'
Setup Details
Include the details about the versions of:
- OS type and version: Ubuntu 20.04
- Python: 3.8
- autokeras: 1.0.12, 1.0.15
- keras-tuner: 1.0.3
- scikit-learn: 0.24.2
- numpy: 1.19.5
- pandas: 1.3.1
- tensorflow: 2.5.0
The only working work-around i'v found
hp = keras_tuner.HyperParameters()
is_bi_1 = hp.Fixed('rnn_block_1/bidirectional', False)
input_node = ak.Input()
prf_regressor = input_node
prf_regressor = ak.RNNBlock(
return_sequences=False
#, bidirectional=False <----- !!!! DO NOT PASS PARAMETER CREATED EARLIER. YOU NEED ONLY TO CREATE IT. IF YOU PASS IT - IT BREAKES
)(prf_regressor)
prf_regressor = ak.RegressionHead()(prf_regressor)
model = ak.AutoModel(
inputs=[input_node],
outputs=[prf_regressor],
hyperparameters=hp
)
```