use of org.tensorflow.SavedModelBundle in project sponge by softelnet.
the class TensorflowTest method testLoadModel.
// TODO @Test
public void testLoadModel() throws Exception {
String modelDir = "examples/tensorflow/estimator/model";
SavedModelBundle bundle = SavedModelBundle.load(modelDir + "/" + SpongeUtils.getLastSubdirectory(modelDir), "serve");
try (Session s = bundle.session()) /* ; Tensor output = s.runner().fetch("MyConst").run().get(0) */
{
Tensor x = Tensor.create(new float[] { 2, 5, 8, 1 });
Tensor y = s.runner().feed("x", x).fetch("y").run().get(0);
logger.info("y = {}", y.floatValue());
}
}
use of org.tensorflow.SavedModelBundle in project zoltar by spotify.
the class TensorFlowModel method create.
/**
* Note: Please use Models from zoltar-models module.
*
* <p>Returns a TensorFlow model given {@link SavedModelBundle} export directory URI and
* {@link Options}.</p>
*/
public static TensorFlowModel create(final URI modelResource, final Options options) throws IOException {
final URI localDir = FileSystemExtras.downloadIfNonLocal(modelResource);
final SavedModelBundle model = SavedModelBundle.load(localDir.toString(), options.tags().toArray(new String[0]));
return new AutoValue_TensorFlowModel(model, options);
}
Aggregations