2017-01-16 39 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())