[英]How to get prediction output from the tensor
Currently, I've finished my functional neuron model from TensorFlow, and I want to output a prediction to the CSV file.目前,我已经从 TensorFlow 完成了我的功能神经元模型,我想将预测输出到 CSV 文件。
However, when I get the prediction, it's a tensor with 8 classes output probability, 428 rows.但是,当我得到预测时,它是一个具有 8 类输出概率、428 行的张量。
0 1 2 3 4 5 6 7
0 0.001258 0.971390 0.000170 0.005542 0.000077 0.002042 0.001015 0.018505
1 0.000663 0.989145 0.000010 0.000393 0.000642 0.000798 0.003435 0.004914
2 0.001139 0.939257 0.000232 0.017595 0.000112 0.000762 0.000535 0.040368
3 0.002857 0.970207 0.000041 0.000680 0.003005 0.000273 0.012651 0.010286
4 0.000706 0.992306 0.000017 0.000533 0.000908 0.000095 0.000808 0.004627
.
.
428
How can I grab the highest probability of each class number as output?如何获取每个类号的最高概率作为输出? For example, the first data point 0, it's clear to see the class 1 has the highest propablility.例如,第一个数据点 0,很明显,类别 1 的概率最高。
Use argmax()
method to get the index with the largest value across axes of a tensor.使用argmax()
方法获取张量轴上具有最大值的索引。
b = [0, 1, 2, 100, 3, 4, 5]
print(np.argmax(b))
3 3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.