使用张量流重新训练的图形与LabelImage示例

时间:2017-06-16 23:02:55

标签: java python tensorflow

我试图在张量流示例中获取由retrain.py生成的输出图,并将其运行回LabelImage.java,以识别我用于重新训练原始初始V3模式的图像。 / p>

Using training made with python API as input to LabelImage module in java API?

中询问了此问题的一个版本

正如最初的问题和答案所指出的,节点名称在用于LabelImage的初始V5模型和由retrain.py生成的输出模型之间发生了变化。

提供的答案确实解决了节点名称混淆,但它引入了另一个问题。图像分类不再有效。我针对初始V5模型运行了LearnImage,给它一张草莓图片,并报告了#34;草莓"。当我将草莓图片运行到重新训练的模型中时(使用答案建议的代码更改),它给了我"郁金香"以答案的名字命名。换句话说,分类失败了。

当我将重新训练的输入和输出节点缝合到第112行的原始LabelImage.java

我收到此错误:

     [java] Exception in thread "main" org.tensorflow.TensorFlowException: Output 0 of type float does not match declared output type string for node _recv_DecodeJpeg/contents_0 = _Recv[client_terminated=true, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=-538792158466408467, tensor_name="DecodeJpeg/contents:0", tensor_type=DT_STRING, _device="/job:localhost/replica:0/task:0/cpu:0"]()

感觉初始V5模型中节点之间的输入/输出与重新训练的V3模型中的节点之间的输入/输出不匹配。我无法找到有关这些模型或其参数的文档或如何进行培训:在LearnImage.java中有评论

      // Some constants specific to the pre-trained model at:
  // https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
  //
  // - The model was trained with images scaled to 224x224 pixels.
  // - The colors, represented as R, G, B in 1-byte each were converted to
  //   float using (value - Mean)/Scale.
  final int H = 224;
  final int W = 224;
  final float mean = 117f;
  final float scale = 1f;

我怀疑这些不适合Retrain.py

的再训练V3模型

想法?

0 个答案:

没有答案
相关问题