ValueError: total size of new array must be unchanged
Posted 牧马人夏峥
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ValueError: total size of new array must be unchanged相关的知识,希望对你有一定的参考价值。
在对数据增强后的faster rcnn中进行训练时,出现这个错误,原因是在lib/roi_data_layer/layer.py中,会出现
inds = np.reshape(inds, (-1,2))
因此有效的roidb需为偶数。
参考https://github.com/rbgirshick/py-faster-rcnn/issues/61可处理数据奇偶问题
#inds = np.reshape(inds, (-1, 2))
#row_perm = np.random.permutation(np.arange(inds.shape[0]))
#inds = np.reshape(inds[row_perm, :], (-1,))
# consider the case when len(inds) is odd
isodd = len(inds) % 2
if not isodd:
inds = np.reshape(inds, (-1,2))
else:
tail = inds[-1]
inds = np.reshape(inds[:-1], (-1,2))
row_perm = np.random.permutation(np.arange(inds.shape[0]))
inds = np.reshape(inds[row_perm, :], (-1,))
if isodd:
inds = np.append(inds, tail)
self._perm = inds
以上是关于ValueError: total size of new array must be unchanged的主要内容,如果未能解决你的问题,请参考以下文章
Buffer Pool Size of Total RAM No data
MYSQL碰到The total number of locks exceeds the lock table size 问题解决记录
解决label-studio的Validation error (Maximum total size of all files is
解决label-studio的Validation error (Maximum total size of all files is
解决label-studio的Validation error (Maximum total size of all files is
sh 命令行中的目录大小(来自http://askubuntu.com/questions/1224/how-do-i-determine-the-total-size-of-a-directory-