java icon indicating copy to clipboard operation
java copied to clipboard

How to input data and recive returned results after loading the categorization model

Open xmings opened this issue 3 years ago • 1 comments
trafficstars

dependency:

            <groupId>org.tensorflow</groupId>
            <artifactId>tensorflow-core-platform</artifactId>
            <version>0.4.1</version>
        </dependency>

code:

import org.{tensorflow=>tf}
val result = tf.SavedModelBundle
      .load("D:\\model\\categorization","serve")
      .session()
      .runner()
      .feed("serving_default_inputs:0", tf.create(List("....", "....")))
      .fetch("StatefulPartitionedCall:0")
      .run()
      .get(0);

However, no any create method found within tf, why ??

xmings avatar Apr 05 '22 15:04 xmings

What do you expect tf.create to do? As far as I can tell there isn't an equivalent method in TF Python.

Depending on what your input looks like you can use the different tensor types (e.g. TFloat32, TInt32) and their factory methods (e.g. scalarOf, vectorOf), or the ndarray library (https://github.com/tensorflow/java-ndarray) to construct the right inputs for your model.

Craigacp avatar Apr 05 '22 16:04 Craigacp