Description
Bug Description
After about 100 trials of autokeras, I routinely run into the following error with the following traceback:
Traceback (most recent call last):
File "C:\Users<user><users-workspace>\ncaa-predictions\build_auto_classification_model.py", line 23, in
results = auto_model.fit(
^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\auto_model.py", line 303, in fit
history = self.tuner.search(
^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\engine\tuner.py", line 239, in search
pipeline = pipeline_module.load_pipeline(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\pipeline.py", line 77, in load_pipeline
return Pipeline.from_config(io_utils.load_json(filepath))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\pipeline.py", line 192, in from_config
preprocessors_module.deserialize(preprocessor)
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\preprocessors_init_.py", line 32, in deserialize
return utils.deserialize_keras_object(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\autokeras\utils\utils.py", line 129, in deserialize_keras_object
return keras.utils.deserialize_keras_object(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\saving\serialization_lib.py", line 694, in deserialize_keras_object
cls = _retrieve_class_or_fn(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\saving\serialization_lib.py", line 810, in _retrieve_class_or_fn
raise TypeError(
TypeError: Could not locate class 'SigmoidPostprocessor'. Make sure custom classes are decorated with@keras.saving.register_keras_serializable()
. Full object config: {'module': 'autokeras.preprocessors.postprocessors', 'class_name': 'SigmoidPostprocessor', 'config': {}, 'registered_name': 'SigmoidPostprocessor'}
Bug Reproduction
Code for reproducing the bug:
import pandas as pd
import autokeras as ak
from sklearn.model_selection import train_test_split
from autokeras.preprocessors import SigmoidPostprocessor
df = pd.read_csv('path/of/data-classification.csv', encoding='utf-8')
X = df[['kenpom_1', 'massey_1', 'sos_1', 'field_goals_1','field_goals_att_1', 'three_points_1', 'three_points_att_1','free_throws_1', 'free_throws_att_1', 'off_rebounds_1','total_rebounds_1', 'turnovers_1','pace_1','effective_fg_pct_1','turnover_pct_1','off_reb_pct_1','ft_per_fga_1', 'opp_field_goals_1','opp_field_goals_att_1', 'opp_three_points_1', 'opp_three_points_att_1','opp_free_throws_1', 'opp_free_throws_att_1', 'opp_off_rebounds_1','opp_total_rebounds_1', 'opp_turnovers_1','opp_pace_1','opp_effective_fg_pct_1','opp_turnover_pct_1','opp_off_reb_pct_1','opp_ft_per_fga_1', 'kenpom_2', 'massey_2','sos_2', 'field_goals_2', 'field_goals_att_2', 'three_points_2','three_points_att_2', 'free_throws_2', 'free_throws_att_2','off_rebounds_2', 'total_rebounds_2', 'turnovers_2','pace_2','effective_fg_pct_2','turnover_pct_2','off_reb_pct_2','ft_per_fga_2','opp_field_goals_2', 'opp_field_goals_att_2', 'opp_three_points_2','opp_three_points_att_2', 'opp_free_throws_2', 'opp_free_throws_att_2','opp_off_rebounds_2', 'opp_total_rebounds_2', 'opp_turnovers_2','opp_pace_2','effective_fg_pct_1','turnover_pct_1','off_reb_pct_1','ft_per_fga_1']].values
y = df[['result']].values
x_train, x_val, y_train, y_val = train_test_split(
X, y, test_size=0.2, random_state=46
)
auto_model = ak.AutoModel(
inputs=[ak.Input()],
outputs=[ak.ClassificationHead(
num_classes=2,
loss='binary_crossentropy'
)],
max_trials=150,
project_name='ncaa_auto_classification'
)
results = auto_model.fit(
x=x_train,
y=y_train,
batch_size=32,
validation_data=[x_val, y_val],
verbose=2
)
Data used by the code:
Attached.
data-classification.csv
Expected Behavior
Autokeras continues to process trials like normal
Setup Details
Include the details about the versions of:
- OS type and version: Windows 11
- Python: 3.12.6
- autokeras: 2.0.0
- keras-tuner: 1.4.7
- scikit-learn: 1.6.1
- numpy: 2.1.3
- pandas: 2.2.3
- tensorflow: 2.19.0