Open
Description
skops io seems to work fine with scikeras models when they haven't been fit, but not when they've been fit. The error message (and potentially underlying cause) is the same as #184
Example code (this works):
from tensorflow import keras
from sklearn.pipeline import Pipeline
from skops.io import dump
from scikeras.wrappers import KerasClassifier
# This simplifies the basic usage tutorial from https://adriangb.com/scikeras/stable/notebooks/Basic_Usage.html
def get_clf(meta):
n_features_in_ = meta["n_features_in_"]
model = keras.models.Sequential()
model.add(keras.layers.Input(shape=(n_features_in_,)))
model.add(keras.layers.Dense(1, activation="sigmoid"))
return model
clf = KerasClassifier(
model=get_clf,
loss="binary_crossentropy"
)
pipeline = Pipeline(
[("classifier", clf)]
)
# These both work
dump(clf, 'keras-test.skops')
dump(pipeline, 'keras-test.skops')
However, running the following then gives a "RecursionError: maximum recursion depth exceeded" on the last line:
import numpy as np
from sklearn.datasets import make_classification
X, y = make_classification(1000, 20, n_informative=10, random_state=0)
clf.fit(X, y)
dump(clf, 'keras-test.skops')
Metadata
Metadata
Assignees
Labels
No labels