10
$\begingroup$

What are the requirements to load the trained model by Keras in Java?

I checked that DeepLearning4J supports Keras models, network architecture and weights can be easily loaded. The only cons are probably that we need to use ND4J backend or it does not matter?

If there is a created model using keras and tensorflow, what is the best way to load it in Java ecosystem?

I tried to use frozen graph script to save tensorflow model, but it cannot be loaded with SavedModel.load. Loading model as a Tensor Graph object seems to be common way, but available examples in Java are chaos especially when input is an image.

$\endgroup$
  • $\begingroup$ what format is your model in? Onnx? $\endgroup$ – ngopal Feb 7 at 22:59
  • $\begingroup$ are you using CPU or GPU? $\endgroup$ – Donald S Jun 14 at 4:52
1
$\begingroup$

Giving you some links which have worked:

deploying-keras-deep-learning-models-with-java : this uses DeepLearning4J, ND4J which supposedly you have tried already.

tensorflow-keras-java

And same question is asked here - converting-keras-in-python-to-java . It uses KerasModelImport.importKerasSequentialModelAndWeight

You should give HDF5 file operation java examples: hdf-java . It would be helpful if you want to change the weights yourself

Please comment if you have already tried all these already.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.