Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: KeyError: 'text_block_1/max_tokens' #1882

Open
gitzev opened this issue Jun 15, 2023 · 5 comments
Open

Bug: KeyError: 'text_block_1/max_tokens' #1882

gitzev opened this issue Jun 15, 2023 · 5 comments

Comments

@gitzev
Copy link

gitzev commented Jun 15, 2023

Bug Description

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/base_tuner.py", line 270, in _try_run_and_update_trial
self._run_and_update_trial(trial, *fit_args, **fit_kwargs)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/base_tuner.py", line 235, in _run_and_update_trial
results = self.run_trial(trial, *fit_args, **fit_kwargs)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/tuner.py", line 287, in run_trial
obj_value = self._build_and_fit_model(trial, *args, **copied_kwargs)
File "/usr/local/lib/python3.10/dist-packages/autokeras/engine/tuner.py", line 91, in _build_and_fit_model
model = self._try_build(trial.hyperparameters)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/tuner.py", line 155, in _try_build
model = self._build_hypermodel(hp)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/tuner.py", line 146, in _build_hypermodel
model = self.hypermodel.build(hp)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/hypermodel.py", line 115, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/autokeras/graph.py", line 250, in build
outputs = block.build(hp, inputs=temp_inputs)
File "/usr/local/lib/python3.10/dist-packages/autokeras/engine/block.py", line 38, in _build_wrapper
return super()._build_wrapper(hp, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/hypermodel.py", line 115, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/autokeras/blocks/wrapper.py", line 159, in build
output_node = self._build_block(hp, output_node, block_type)
File "/usr/local/lib/python3.10/dist-packages/autokeras/blocks/wrapper.py", line 165, in _build_block
max_tokens = self.max_tokens or hp.Choice(
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/hyperparameters/hyperparameters.py", line 295, in Choice
return self._retrieve(hp)
File "/usr/local/lib/python3.10/dist-packages/keras_tuner/engine/hyperparameters/hyperparameters.py", line 203, in _retrieve
return self.values[hp.name]
KeyError: 'text_block_1/max_tokens'

Bug Reproduction

When fit the model on random trial i have error. It can be trial=7 or trial =63
model2 = ak.AutoModel(
inputs=[ak.TextInput(), ak.StructuredDataInput()],
outputs=[
ak.RegressionHead(metrics=["mae"])
],
overwrite=False,
max_trials=100,
objective ='val_mae'
)
model2.fit(
[texts_all_np_train, xTrain_train],
y_train,
epochs=8,
validation_split=0.2
)

Data used by the code:
texts_all_np_train= df['Stage_Description'].values #str

Expected Behavior

Setup Details

Include the details about the versions of:

  • OS type and version: google colab
  • Python: 3.10
  • autokeras: <1.1.0>
  • keras-tuner: 1.3.5
  • scikit-learn: 1.2.2
  • numpy: 1.22.4
  • pandas: 1.5.3
  • tensorflow: 2.12.0

Additional context

@krishnayah
Copy link

I'm getting this issue too, were you able to fix it?

@tamio0800
Copy link

Me, too 😕

@Gvorlv
Copy link

Gvorlv commented Nov 7, 2023

I have encountered a similar error.

Search: Running Trial #5

Value |Best Value So Far |Hyperparameter
vanilla |vanilla |text_block_1/block_type
none |none |text_block_1/embedding_1/pretraining
64 |64 |text_block_1/embedding_1/embedding_dim
0.25 |0.25 |text_block_1/embedding_1/dropout
5 |5 |text_block_1/conv_block_1/kernel_size
False |False |text_block_1/conv_block_1/separable
False |False |text_block_1/conv_block_1/max_pooling
1 |1 |text_block_1/conv_block_1/num_blocks
1 |1 |text_block_1/conv_block_1/num_layers
256 |256 |text_block_1/conv_block_1/filters_0_0
128 |128 |text_block_1/conv_block_1/filters_0_1
0 |0 |text_block_1/conv_block_1/dropout
64 |64 |text_block_1/conv_block_1/filters_1_0
32 |32 |text_block_1/conv_block_1/filters_1_1
0 |0 |classification_head_1/dropout
sgd |adam |optimizer
0.001 |0.001 |learning_rate

Traceback (most recent call last):
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 273, in _try_run_and_update_trial
self._run_and_update_trial(trial, *fit_args, **fit_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 238, in _run_and_update_trial
results = self.run_trial(trial, *fit_args, **fit_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 314, in run_trial
obj_value = self._build_and_fit_model(trial, *args, **copied_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\engine\tuner.py", line 91, in _build_and_fit_model
model = self._try_build(trial.hyperparameters)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 164, in _try_build
model = self._build_hypermodel(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 155, in _build_hypermodel
model = self.hypermodel.build(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hypermodel.py", line 120, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\graph.py", line 250, in build
outputs = block.build(hp, inputs=temp_inputs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\engine\block.py", line 38, in _build_wrapper
return super()._build_wrapper(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hypermodel.py", line 120, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\blocks\wrapper.py", line 159, in build
output_node = self._build_block(hp, output_node, block_type)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\blocks\wrapper.py", line 165, in _build_block
max_tokens = self.max_tokens or hp.Choice(
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hyperparameters\hyperparameters.py", line 300, in Choice
return self._retrieve(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hyperparameters\hyperparameters.py", line 208, in _retrieve
return self.values[hp.name]
KeyError: 'text_block_1/max_tokens'
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\tasks\text.py", line 160, in fit
history = super().fit(
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\auto_model.py", line 292, in fit
history = self.tuner.search(
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\engine\tuner.py", line 193, in search
super().search(
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 234, in search
self.on_trial_end(trial)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 338, in on_trial_end
self.oracle.end_trial(trial)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\oracle.py", line 108, in wrapped_func
ret_val = func(*args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\oracle.py", line 586, in end_trial
self._check_consecutive_failures()
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\oracle.py", line 543, in _check_consecutive_failures
raise RuntimeError(
RuntimeError: Number of consecutive failures exceeded the limit of 3.
Traceback (most recent call last):
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 273, in _try_run_and_update_trial
self._run_and_update_trial(trial, *fit_args, **fit_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\base_tuner.py", line 238, in _run_and_update_trial
results = self.run_trial(trial, *fit_args, **fit_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 314, in run_trial
obj_value = self._build_and_fit_model(trial, *args, **copied_kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\engine\tuner.py", line 91, in _build_and_fit_model
model = self._try_build(trial.hyperparameters)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 164, in _try_build
model = self._build_hypermodel(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\tuner.py", line 155, in _build_hypermodel
model = self.hypermodel.build(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hypermodel.py", line 120, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\graph.py", line 250, in build
outputs = block.build(hp, inputs=temp_inputs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\engine\block.py", line 38, in _build_wrapper
return super()._build_wrapper(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hypermodel.py", line 120, in _build_wrapper
return self._build(hp, *args, **kwargs)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\blocks\wrapper.py", line 159, in build
output_node = self._build_block(hp, output_node, block_type)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\autokeras\blocks\wrapper.py", line 165, in _build_block
max_tokens = self.max_tokens or hp.Choice(
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hyperparameters\hyperparameters.py", line 300, in Choice
return self._retrieve(hp)
File "C:\Users\yvorlv\miniconda3\envs\tensorflow\lib\site-packages\keras_tuner\engine\hyperparameters\hyperparameters.py", line 208, in _retrieve
return self.values[hp.name]
KeyError: 'text_block_1/max_tokens'

@deathsaber
Copy link

I am facing this issue too on auto-keras == 1.1.0.
This seems to happen when the tuner is set to either of 'bayesian', 'hyperband' or 'random'.

@haifeng-jin
Copy link
Collaborator

Contribution is welcome on this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants