Comments (2)
According to comments in the Keras source code, the scikit-learn wrapper is deprecated and the scikeras external lib should be used. (As I was not following Keras development, this surprised me as well, I think it is a recent decision.)
Can you try using scikeras?
Just a side-note, I am planning on adding custom minimal wrappers that will make sure things like this doesn't happen in the future.
from modal.
I think you can also write a customer Class, whose structure is just like sklearn model:
For example a transferlearning model using Keras could be:
class TransferLearning():
"""
pure active transfer learning
"""
def __init__(self) -> None:
# load the pre-trained encoder
model_path = "./Encoder_models/27_02_2022__23_06_08"
base_model = keras.models.load_model(model_path)
# fix the non-trainable part
self.fixed_model = tf.keras.models.Model(inputs=base_model.input, outputs=base_model.get_layer("flatten_12").output)
self.fixed_model.trainable = False
self.feature_num = base_model.get_layer("feature").output.get_shape().as_list()[1]
def fit(self, X, y):
# add the trainable part on the top
self.extractor = Sequential()
self.extractor.add(self.fixed_model)
self.extractor.add(Dense(self.feature_num, activation='relu', name="feature"))
self.extractor.add(Dense(y.shape[1], activation='softmax', name="prob"))
self.extractor.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
# fine-tune the extractor
self.extractor.fit(X, y, epochs=1, batch_size=32, verbose=0)
def predict(self, X):
return self.extractor.predict(X)
def score(self, X, y):
_, accuracy = self.extractor.evaluate(X, y, verbose=0)
return accuracy
def predict_proba(self, X):
predictor = Model(inputs=self.extractor.input, outputs=self.extractor.get_layer("prob").output)
return predictor.predict(X)
from modal.
Related Issues (20)
- Code for first image HOT 1
- keras image classification model using AL
- Error
- Multivariate Active regression
- How to extract the image names and labels in the training set after completing the active learning loop and write them to a CSV file
- decision_function instead of predict_proba HOT 5
- AttributeError: bootstrap_init HOT 3
- TypeError: cannot concatenate object of type '<class 'numpy.ndarray'>'; only Series and DataFrame objs are valid
- Can I use modAL with estimators from other libraries than scikit-learn like xgboost? HOT 1
- Which sampling method is best for very unbalanced data? HOT 1
- Encountering error with number of batches per epoch
- mmdetection integration with modAL
- Adding active learning regression implementations based on greedy sampling HOT 2
- modAL not installable via pypi anymore HOT 3
- the modAL package has been changed into modal in the pip repository HOT 7
- Data augmentation with `skorch`
- QBC approach for multi-class classification
- Suggestion on how to improve acquisition.UCB for active GP example HOT 1
- QBC stratified bootstrapping HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modal.