Python 关于多维数组唯一数的计数输出
预测模型生成多维数组。我想检查这个数组的值。这是我的密码Python 关于多维数组唯一数的计数输出,python,numpy,scipy,Python,Numpy,Scipy,预测模型生成多维数组。我想检查这个数组的值。这是我的密码 print('Predictions shape ',predictions.shape) unique_items, counts = np.unique(predictions,return_counts=True) print('unique_items ',unique_items) print('counts ',counts) 这就是结果。我不太理解用黄色标记的
print('Predictions shape ',predictions.shape)
unique_items, counts = np.unique(predictions,return_counts=True)
print('unique_items ',unique_items)
print('counts ',counts)
这就是结果。我不太理解用黄色标记的输出项。为什么它不能给出准确的值而不是1…
。谢谢
这只是numpy阵列的打印输出 您可以自己设置
线宽
和边缘
试试这个:
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
并打印()
这只是numpy阵列的打印输出
您可以自己设置线宽
和边缘
试试这个:
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
并打印()
…
不是值估计。这仅仅意味着数组被连接到屏幕上。只显示前几个和最后几个元素。您想知道为什么打印输出是这样的吗?这只是因为阵列的长度对于控制台来说太长。尝试使用打印唯一的\u项[0:5]
该…
不是值估计。这仅仅意味着数组被连接到屏幕上。只显示前几个和最后几个元素。您想知道为什么打印输出是这样的吗?这只是因为阵列的长度对于控制台来说太长。尝试打印唯一的\u项[0:5]