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

もう一つの方法は、listnp.arrayを変換して印刷することであろうと(docs

# beware, this takes like forever :) 
print('unique_items ',unique_items.tolist()) 
print('counts ',counts.tolist()) 
関連する問題