0

I'm using CalibratedClassifierCV to calibrate the probabilities of my CNN model. I'm using the following code:

from tensorflow.keras.models import load_model
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier
from sklearn.calibration import CalibratedClassifierCV
def load_model(*args, **kwargs):
    path="my_model.hd5"
    model = load_model(path)
    return model

clf = KerasClassifier(build_fn=load_model)
calib = CalibratedClassifierCV(clf, cv='prefit', method='sigmoid')
calib.fit(X_train, y_train)

When using this code I'm getting the error message AttributeError: 'KerasClassifier' object has no attribute 'model'. Also when I use clf.predict(X_test) I'm getting the same error. So something seems to be wrong with KerasClassifier.

Is there a mistake in my code?

1 Answer 1

1

You redefined keras' load_model function (from tensorflow.keras.models import load_model) with a namesake (def load_model(*args, **kwargs)) - that may be the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.