Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

python - Is the a way for a loaded Keras Model wrapped into a KerasClassifier without fitting(No Training)

def get_model():
    return load_model("model.h5")

model = KerasClassifier(build_fn = get_model)
# model.fit(X_train,y_train)

plt.figure(figsize=(10,8))
display = plot_partial_dependence(
       model, TrainX, features, fig=fig
)

I dont want to retrain the model as it will change the model that I was trying to evaluate

question from:https://stackoverflow.com/questions/65898367/is-the-a-way-for-a-loaded-keras-model-wrapped-into-a-kerasclassifier-without-fit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As I understand,
IF you are trying to import .h5 files of a pre-trained model and use that for the predict : then, Yes. you can

from tensorflow.keras.models import load_model

model = load_model("path to .h5 files")
## if there is a separate weight file
model.load_weights("path to weight .h5 file")

after that, you can use model variable for predictions.

but
If you are trying to see how the model is trained, then you have to get log files for a particular training instance. And use tensorboard to visualize easily.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...