autokeras icon indicating copy to clipboard operation
autokeras copied to clipboard

KeyError: 'classification_head_1/spatial_reduction_1/reduction_type' with 'overwrite=True' & AK 1.0.17

Open mmortazavi opened this issue 2 years ago • 0 comments

Bug Description

Similar issue to #1183 even with overwrite=True and Autokeras 1.0.17

Bug Reproduction

A simple image classification as given in the tutorials.

Data used by the code: Normal jpg images.

Expected Behavior

The training continues to the maximal max_trials, then stops.

Setup Details

Include the details about the versions of:

  • OS type and version: Ubuntu 20.04.3 LTS
  • Python: 3.9.10
  • autokeras: 1.0.17
  • keras-tuner: 1.1.0
  • scikit-learn: 0.24.1
  • numpy: 1.22.2
  • pandas: 1.2.3
  • tensorflow: 2.8.0

Additional context, here is the full stack trace:

Trial 3 Complete [10h 14m 30s]
val_loss: 0.29048436880111694

Best val_loss So Far: 0.29048436880111694
Total elapsed time: 12h 58m 04s
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [7], in <module>
      1 tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)
      3 model = ak.ImageClassifier(overwrite=True, max_trials=30)
----> 4 history = model.fit(train_data, epochs=10, callbacks=[tensorboard_callback])

File ~/Git/ipig/venv/lib/python3.9/site-packages/autokeras/tasks/image.py:164, in ImageClassifier.fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)
    107 def fit(
    108     self,
    109     x: Optional[types.DatasetType] = None,
   (...)
    117     **kwargs
    118 ):
    119     """Search for the best model and hyperparameters for the AutoModel.
    120 
    121     It will search for the best model based on the performances on
   (...)
    162             validation loss values and validation metrics values (if applicable).
    163     """
--> 164     history = super().fit(
    165         x=x,
    166         y=y,
    167         epochs=epochs,
    168         callbacks=callbacks,
    169         validation_split=validation_split,
    170         validation_data=validation_data,
    171         **kwargs
    172     )
    173     return history

File ~/Git/ipig/venv/lib/python3.9/site-packages/autokeras/auto_model.py:288, in AutoModel.fit(self, x, y, batch_size, epochs, callbacks, validation_split, validation_data, verbose, **kwargs)
    283 if validation_data is None and validation_split:
    284     dataset, validation_data = data_utils.split_dataset(
    285         dataset, validation_split
    286     )
--> 288 history = self.tuner.search(
    289     x=dataset,
    290     epochs=epochs,
    291     callbacks=callbacks,
    292     validation_data=validation_data,
    293     validation_split=validation_split,
    294     verbose=verbose,
    295     **kwargs
    296 )
    298 return history

File ~/Git/ipig/venv/lib/python3.9/site-packages/autokeras/engine/tuner.py:193, in AutoTuner.search(self, epochs, callbacks, validation_split, verbose, **fit_kwargs)
    191 self.hypermodel.build(hp)
    192 self.oracle.update_space(hp)
--> 193 super().search(
    194     epochs=epochs, callbacks=new_callbacks, verbose=verbose, **fit_kwargs
    195 )
    197 # Train the best model use validation data.
    198 # Train the best model with enough number of epochs.
    199 if validation_split > 0 or early_stopping_inserted:

File ~/Git/ipig/venv/lib/python3.9/site-packages/keras_tuner/engine/base_tuner.py:169, in BaseTuner.search(self, *fit_args, **fit_kwargs)
    167 self.on_search_begin()
    168 while True:
--> 169     trial = self.oracle.create_trial(self.tuner_id)
    170     if trial.status == trial_module.TrialStatus.STOPPED:
    171         # Oracle triggered exit.
    172         tf.get_logger().info("Oracle triggered exit")

File ~/Git/ipig/venv/lib/python3.9/site-packages/keras_tuner/engine/oracle.py:189, in Oracle.create_trial(self, tuner_id)
    187     values = None
    188 else:
--> 189     response = self.populate_space(trial_id)
    190     status = response["status"]
    191     values = response["values"] if "values" in response else None

File ~/Git/ipig/venv/lib/python3.9/site-packages/autokeras/tuners/greedy.py:153, in GreedyOracle.populate_space(self, trial_id)
    151 for _ in range(self._max_collisions):
    152     hp_names = self._select_hps()
--> 153     values = self._generate_hp_values(hp_names)
    154     # Reached max collisions.
    155     if values is None:

File ~/Git/ipig/venv/lib/python3.9/site-packages/autokeras/tuners/greedy.py:189, in GreedyOracle._generate_hp_values(self, hp_names)
    186 if hps.is_active(hp):
    187     # if was active and not selected, do nothing.
    188     if best_hps.is_active(hp.name) and hp.name not in hp_names:
--> 189         hps.values[hp.name] = best_hps.values[hp.name]
    190         continue
    191     # if was not active or selected, sample.

KeyError: 'classification_head_1/spatial_reduction_2/reduction_type'

mmortazavi avatar Feb 10 '22 09:02 mmortazavi