Bug: StructuredDataClassifier ignores loss parameter
DF-Damm opened this issue · 0 comments
DF-Damm commented
Bug Description
The StructuredDataClassifier trains with default loss and ignores any user input. Even setting the loss to some random string like loss='this is not a loss'
does not change the behavior (or result in an error).
Bug Reproduction
import tensorflow as tf
import autokeras as ak
TRAIN_DATA_URL = "https://storage.googleapis.com/tf-datasets/titanic/train.csv"
TEST_DATA_URL = "https://storage.googleapis.com/tf-datasets/titanic/eval.csv"
train_file_path = tf.keras.utils.get_file("train.csv", TRAIN_DATA_URL)
test_file_path = tf.keras.utils.get_file("eval.csv", TEST_DATA_URL)
# Initialize the structured data classifier.
clf = ak.StructuredDataClassifier(
overwrite=True, max_trials=3, loss='mse'
)
# Feed the structured data classifier with training data.
clf.fit(
# The path to the train.csv file.
train_file_path,
# The name of the label column.
"survived",
epochs=10,
)
# Print loss function used during training
model = clf.export_model()
print('loss function:', model.loss)
Expected Behavior
The model is supposed to be trained using the mean squared error, but it is actually being trained using <keras.losses.BinaryCrossentropy>.
Setup Details
- OS: Windows
- Python: 3
- autokeras: 1.0.20
- keras-tuner: 1.1.3
- scikit-learn: 1.0.2
- numpy: 1.21.5
- pandas: 1.5.1
- tensorflow: 2.9.1
Additional context
Upon examining the code, it appears that the user input is being overwritten at this point.
#1608 raises a similar issue as a feature request.