张量流预测和标签

tensorfllow prediction and label

嘿,我在张量流中构建了一个神经网络,我想用它来对声音进行分类,我想看看预测的结果(它的标签和标签的分数)

我正在使用这条线来获取分数

values, indices = tf.nn.top_k(x,10) //where x is the input

有了这个我可以得到分数但不能得到相关的标签有什么我可以附加到这个或我必须定义的标签来将分数映射到标签吗?

您可以通过检索 sess.run 的输出来获得您的预测和标签。

x = tf.placeholder(...) # x inputs
y_true = tf.placeholder(...) # labels

logits = ... # neural network model

predictions = tf.nn.softmax(logits) # prediction tensor

init_op = tf.initialize_all_variables()

with tf.Session() as sess:
    sess.run(init_op)

    # get run outputs
    pred, labels = sess.run([predictions, y_true],
                            feed_dict={x: x_inputs, y_true: y_inputs) 

# do something with the outputs
print labels
pd.Dataframe(data=pred)