Tensorflow Java API - A Complex Example

I already asked the question as a github question, but was redirected here. I saw an example to import a model created and trained in Python, imported into Java code and used for predictions. However, I had problems understanding what was actually going on, especially in this block and the declaration of the GraphBuilder class between lines 156-207 . Can someone please give them some explanation?

Also, I know that the Java API is still under development. However, I would be interested if more complex examples can be seen, if possible, including:

  • import the model into Java and then do the model training

  • implementing, training, evaluating, saving, loading a model from scratch in Java using Tensorflow

Does anyone have such an example and are willing to share it?

Thanks for the help!

Greetings

Peter

+4
source share
2 answers

The specified code block generates a TensorFlow graph to “normalize” the image so that the image can be fed to another TensorFlow graph (start). Python achieves the equivalent of something like this:

image = tf.cast(tf.image.decode_jpeg(input, channels = 3), tf.float32)
batch = tf.expand_dims(image, 0);
resized = tf.image.resize_bilinear(dims_expander, [input_height, input_width])
normalized = tf.divide(tf.subtract(resized, [input_mean]), [input_std])

Python TensorFlow (, tf.cast, tf.image.decode_jpeg ..) ops TensorFlow. Java API, , GraphBuilder.

, .

, , .

+2

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


All Articles