Recently, I have a project of using neural networks to learn and recognize certain patterns from text. The project by itself is an interesting problem which I ended up using conditional random field aided by recurrent neural network to solve. Once the model has been trained, I needed to write up a Java library to make the model accessible from JVM process.
The deep learning library I have been using is TensorFlow. I know Pytorch is picking up steams steadily in recent years, but to me TensorFlow is really the best choice for building up any applications of industrial strength, given its incredibly diversified set of client languges one can choose from. Luckily Java is one of those client languages.
TensorFlow defines a class SavedModelBundle that one can use to export the model onto the disk that any client languages TensorFlow supports can then read from. When the model is imported into the process, the way to use it is as simple as: 1. feeding the input tensors with the actual input values