有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Tensorflow:如何在java中使用python训练的语音识别模型

我有一个用python训练的tensorflow模型,通过遵循this article.在训练之后,我生成了冻结图现在我需要使用这个图,并在基于JAVA的应用程序上生成识别。 为此,我看了下面的example。然而,我不明白的是如何收集我的输出。我知道我需要为图表提供3个输入

从官方教程中给出的示例中,我已经阅读了基于python的代码

def run_graph(wav_data, labels, input_layer_name, output_layer_name,
              num_top_predictions):
  """Runs the audio data through the graph and prints predictions."""
  with tf.Session() as sess:
    # Feed the audio data as input to the graph.
    #   predictions  will contain a two-dimensional array, where one
    #   dimension represents the input image count, and the other has
    #   predictions per class
    softmax_tensor = sess.graph.get_tensor_by_name(output_layer_name)
    predictions, = sess.run(softmax_tensor, {input_layer_name: wav_data})

    # Sort to show labels in order of confidence
    top_k = predictions.argsort()[-num_top_predictions:][::-1]
    for node_id in top_k:
      human_string = labels[node_id]
      score = predictions[node_id]
      print('%s (score = %.5f)' % (human_string, score))

    return 0

有人能帮我理解tensorflow java api吗


共 (0) 个答案