What is the tensorflow java API for tf.train.Example.SerializeToString in python?

2020-08-15T07:57:44

Trying to convert some python tensorflow code to java, I can't find the same java API for train.example.SerializeToString in python. It is surely not java toString. I can find the java Example class here https://www.javadoc.io/doc/org.tensorflow/proto/latest/org/tensorflow/example/package-summary.html but there are simply no such API as SerializeToString.

in Python

features["a"] = tf.train.Feature(int64_list=tf.train.Int64List(value=list(values_a)))
features["b"] = tf.train.Feature(int64_list=tf.train.Int64List(value=list(values_b)))
tf_example = tf.train.Example(features=tf.train.Features(feature=features))
model_input = tf_example.SerializeToString()

I can convert to java

Feature featureA = Feature.newBuilder().setInt64List(value_a).build();
Feature featureB = Feature.newBuilder().setInt64List(value_b).build();
Map<String, Feature> featureNameAndValueMap = new HashMap<>();
featureNameAndValueMap.put("a", featureA);
featureNameAndValueMap.put("b", featureB);
Example example = Example.newBuilder().setFeatures(features).build();
//String modelInput = example.to???

Thanks a lot

Copyright License:
Author:「David chang」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/63421332/what-is-the-tensorflow-java-api-for-tf-train-example-serializetostring-in-python

About “What is the tensorflow java API for tf.train.Example.SerializeToString in python?” questions

Trying to convert some python tensorflow code to java, I can't find the same java API for train.example.SerializeToString in python. It is surely not java toString. I can find the java Example clas...
Trying to convert some python tensorflow code to java, I can't find the same java API for train.example.SerializeToString in python. It is surely not java toString. I can find the java Example clas...
I am trying to execute a TF saved model in Java and running into the following exception: Exception in thread &quot;main&quot; org.tensorflow.exceptions.TFInvalidArgumentException: Could not parse
I am using the Tensorflow Java Api to load an already created Tensorflow model into the JVM. I am using this as an example: tensorflow/examples/LabelImage.java Here is my simple scala code: impor...
Background: I am new to Tensorflow and AI and wish to try out Tensorflow in a Java based environment. Found Tensorflow has a Java API and tried it out but results don't seem to be similar to my Pyt...
I'm trying to run Tensorflow in Android, using Tensorflow's Java API. I'm wondering how to set the Session config when creating a Session object. In the Python API, you can do this by using the "c...
I have already asked the question as a github issue, but was redirected to here. I have seen the example for importing model created and trained in Python imported into Java code and used for predi...
Does any one know of high level api if exist in java for directly reading tfrecords and feeding to a tensorflow savedModel . Python api allows both example.proto (tfrecords) and tensors to be fed t...
What would be the best way to achieve an iterative eigendecomposition using TensorFlow? (something like matlabs eigs). I know that Eigen has the ability to perform an eigendecomposition, but it is
What's the best way to classify batch of images using TensorFlow java API? I also want the capability to resize the image in GPU so that all the images in the batch are of same dimension. The only

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.