Use keras with tensor flow function

I was wondering how to use my model prepared with keras on a production server. I heard about working with tensor, but I can't figure out how to use it with my keras model.

I found this link: https://blog.keras.io/keras-as-a-simplified-interface-to-tensorflow-tutorial.html

But I do not know how to initialize the sess variable, since my model is already trained and that’s it. Is there any way to do this?

+5
source share
2 answers

You can initialize your session variable as

from keras import backend as K sess = K.get_session() 

and export the model as in a workbook (note that the import for the exporter has changed )

 from tensorflow.contrib.session_bundle import exporter K.set_learning_phase(0) export_path = ... # where to save the exported graph export_version = ... # version number (integer) saver = tf.train.Saver(sharded=True) model_exporter = exporter.Exporter(saver) signature = exporter.classification_signature(input_tensor=model.input, scores_tensor=model.output) model_exporter.init(sess.graph.as_graph_def(), default_graph_signature=signature) model_exporter.export(export_path, tf.constant(export_version), sess) 
+8
source

A good alternative to TensorFlow Serving is TensorCraft , a simple HTTP server that stores models (I am the author of this tool). Currently, only the format of the saved TensorFlow model is supported.

Before using the model, you must export it using the TensorFlow API, pack it in TAR and send it to the server.

You can find more detailed information in the project documentation .

0
source

Source: https://habr.com/ru/post/1260823/


All Articles