问题:ValueError: total size of new array must be unchanged
在用Faster Rcnn训练数集的时候,出现报错
I0730 20:59:18.449447 20748
upgrade_proto.cpp:66] Attempting to upgrade
input file specified using deprecated input
fielTraceback (most recent call last):
File "./tools/train_net.py", line 112, i <module>
max_iters=args.max_iters)
File "E:\1-XPJ\py-faster-rcnn\tools\..\lib\fast_rcnn\train.py", line 157, in train_net
pretrained_model=pretrained_model)
File "E:\1-XPJ\py-faster-rcnn\tools\..\lib\fast_rcnn\train.py", line 53, in __init__
self.solver.net.layers[0].set_roidb(roidb)
File "E:\1-XPJ\py-faster-rcnn\tools\..\lib\roi_data_layer\layer.py", line 68, in set_roidb
self._shuffle_roidb_inds()
File "E:\1-XPJ\py-faster-rcnn\tools\..\lib\roi_data_layer\layer.py", line 35, in _shuffle_roidb_inds
inds = np.reshape(inds, (-1, 2))
File "C:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 224, in reshape
return reshape(newshape, order=order)
ValueError: total size of new array must be unchanged
ds: data/imagenet_models/ZF.v2.caffemodel
问题分析
这里是 reshape方法报错,
reshape方法可以实现数组的变形,例如:
>>> from numpy import *
>>> a = array([1,2,3,4])
>>> a.reshape(2, 2)
<<< a = ([1,2],[3,4])
如果
>>> from numpy import *
>>> a = array([1,2,3])
>>> a.reshape(2, 2)
则会报错
ValueError: total size of new array must be unchanged
解决方案
确保tarin.txt, trainval.txt里的文件数量为偶数