2017-01-16 57 views
1

存在从预测模型生成的多维数组。我想检查这个数组的值。这是我的代码。关于计数多维数组的唯一编号的输出

print('Predictions shape ',predictions.shape)   
    unique_items, counts = np.unique(predictions,return_counts=True)   
    print('unique_items ',unique_items) 
    print('counts ',counts) 

这就是结果。我不太了解标有黄色的输出项目。为什么它不能给出确切的值而不是1...。谢谢。

enter image description here

+0

了' ......不是价值估计。它只是意味着阵列被连接在屏幕上。只显示前几个和最后几个元素。 – DeepSpace

+0

你想知道为什么打印输出看起来像这样?这只是因为控制台数组的长度太长。试试'print unique_items [0:5]' – ppasler

回答

0

这仅仅是一个numpy的阵列的打印输出。

您可以设置linewidthedgeitems自己numpy.set_printoptions

试试这个:

import numpy as np 

np.set_printoptions(linewidth=1000, edgeitems=5) 

predictions = np.random.rand(3249, 4096, 2) 

print('Predictions shape ',predictions.shape)   
unique_items, counts = np.unique(predictions,return_counts=True)   
print('unique_items ',unique_items) 
print('counts ',counts) 

另一种方法是将np.array转换为list并打印(docs

# beware, this takes like forever :) 
print('unique_items ',unique_items.tolist()) 
print('counts ',counts.tolist())