keras-team / autokeras

AutoML library for deep learning
http://autokeras.com/
Apache License 2.0
9.1k stars 1.4k forks source link

Bug: StructuredDataClassifier ignores loss parameter #1874

Open DF-Damm opened 1 year ago

DF-Damm commented 1 year ago

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 .

Setup Details

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.