简体   繁体   中英

What's the most efficient and/or easy way of exporting and using a TensorFlow model

Ive created a time series forecasting model (RNN) which is heavily based off this tutorial , If I wanted to export this model and use it with, say, a kivy UI in python, where I feed it some new data every time the program is run and it predicts a small range of values, how would I go about doing that? I tried to look into the SavedModel stuff but im not sure how to implement the model after exporting it.

It is easy you saved using the log, checkpoint format where you can save and restore directly but the models you need to be specific by target load model. Do it the easy way you will not headaches later.

: Callback

cp_callback = tf.keras.callbacks.ModelCheckpoint(checkpoint_path, monitor='val_loss', verbose=0, save_best_only=True, mode='min' ) tb_callback = tf.keras.callbacks.TensorBoard(log_dir, update_freq=15)

: Loads the weights

if exists(checkpoint_path): model_highscores.load_weights(checkpoint_path) print("model load: " + checkpoint_path) input("Press Any Key!")

: Usage

predictions = model_highscores.predict(img_array)

从内部屏幕范围预测 来自外部输入的预测 语言的可能性 再次通过语言的可能性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM