小编gag*_*tra的帖子

使用估计器在 Java 中加载/提供 tensorflow 模型时出现问题

我使用了人口普查数据并使用 tensorflow 中的 estimators api 创建了一个广泛而深入的模型。在 Java 中加载模型时,似乎存在一个错误,不允许加载模型。异常看起来像

Exception in thread "main" org.tensorflow.TensorFlowException: Op type not 
registered 'SparseFeatureCross' in binary running on gmalhotra-mba-2.local. 
Make sure the Op and Kernel are registered in the binary running in this 
process.
at org.tensorflow.SavedModelBundle.load(Native Method)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:39)
at deeplearning.DeepLearningTest.main(DeepLearningTest.java:32)
Run Code Online (Sandbox Code Playgroud)

请在下面找到用于保存模型的python代码:https : //gist.github.com/gaganmalhotra/cd6a5898b9caf9005a05c8831a9b9153

使用的Java代码如下:

    public static void main(String[] args) {
          try (SavedModelBundle b = SavedModelBundle.load("/Users/gagandeep.malhotra/Documents/SampleTF_projects/temporaryModel/1510624417/", "serve")) {


    Session sess = b.session();

                //Create the input sensor 
                  float[][] mat=new float[1][1];
                  mat[0]=new float[]{0.5f};

                // create tensors specific …
Run Code Online (Sandbox Code Playgroud)

java tensorflow tensorflow-serving

1
推荐指数
1
解决办法
1596
查看次数

标签 统计

java ×1

tensorflow ×1

tensorflow-serving ×1