Numpy拒绝展平2D数组(展平,拉平,重塑,索引均失败)

时间:2018-09-12 23:23:51

标签: python numpy scipy numpy-ndarray

我不能为此做头或尾。

我有一个numpy拒绝展平的二维numpy数组!我尝试了4种不同的方法来展平它,但是所有方法都失败了。

cluster_model是sklearn RadiusNeighborsClassifier。

cluster_model.fit(p_training_features, my_training_labels)
neighbor_graph = neighbor_graph.astype('?')
print(neighbor_graph.shape)
total_votes = neighbor_graph.sum(axis=0)
print(total_votes)
print(total_votes.shape)
total_votes = total_votes[0]
print(total_votes.shape)
total_votes = total_votes.flatten()
print(total_votes.shape)
total_votes = total_votes.ravel()
print(total_votes.shape)
total_votes = total_votes.reshape(-1,)
print(total_votes.shape)
flattened_total_votes = total_votes[0]
print(flattened_total_votes.shape)

输出为...

(10000, 20000)
[[722 622 606 ...   0   2   0]]
(1, 20000)
(1, 20000)
(1, 20000)
(1, 20000)
(1, 20000)
(1, 20000)

当我打印矩阵时,它显示为稠密...,我试图进行到稠密的转换,但是由于total_votes已经稠密,所以它指示了错误。我想不出阵列未展平的其他原因。

0 个答案:

没有答案
相关问题