简体   繁体   中英

How to load and predict a pre-trained tensorflow model into Java code?

I am not sure what's the common practice to load a pre-trained keras model into a Java code?

I saw deeplearning4j and Google's native Java support .

Surprisingly, google says:

Caution: The TensorFlow Java API is not covered by the TensorFlow API stability guarantees.

I am really confused, what's going on here and what are consideration I need to take before choosing a tensorflow Java engine. Obviously I would like to support the latest CUDA/ cuDNN. My application runs on PCs it's not a mobile application.

You can follow these steps :

  1. You can use TensorFlow Lite or TensorFlow Mobile. TensorFlow Lite is recommended. Visit here .
  2. TensorFlow Lite has a gradle as well as maven dependency which is useful in Android and java.
  3. To convert your python model to TF Lite file use functions in this notebook
  4. It can run inferences on the model which you trained in python. But, TF Lite has issues with LSTM cells and BatchNormalization layers.

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