我有这个numpy数组:
array([ 0.49010508, 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0.09438115, 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ,
-1. , -1. , -1. , -1. , -1. ,
-1. , -1. , -1. , -1. , -1. ,
-1. , -1. ])
这是名为allSimilarity
的5D numpy数组的第一行。我用np.full()
定义了它,fill_value
是-1。计算之后,我想删除最后一个无用的-1
值。所以,我计算了尺寸差异,但是当我使用np.delete()
或np.resize()
或allSimilarity[index1][index2][index3][index4] = allSimilarity[index1][index2][index3][index4][:diff].copy()
(其中diff
是旧尺寸和新尺寸之间的尺寸差异时)我得到了这个错误:
ValueError: could not broadcast input array from shape (55) into shape (67)
有什么建议吗?
提前致谢。
答案 0 :(得分:1)
希望这有帮助。
[ 0.49010508 0. 0. 0. 0. 0. 0.
0. 0.09438115 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. ]
<强>结果:强>
.pre('save',