In Chapter 10, Deploying on a Distributed System, Importing Python Models in the JVM with DL4J section, we learned how to import existing Keras models into DL4J and use them to make predictions or re-train them in a JVM-based environment.
This applies to the model we implemented and trained in the Hand-on NLP with Keras and TensorFlow backend section in Python, using Keras with a TensorFlow backed. We need to modify the code for that example to serialize the model in HDF5 format by doing the following:
model.save('sa_rnn.h5')
The sa_rnn.h5 file produced needs to be copied into the resource folder for the Scala project to be implemented. The dependencies for the project are the DataVec API, the DL4J core, ND4J, and the DL4J model import library.
We need to import and transform the Large Movie Review database as explained...