Traceback (most recent call last):
File "G:/yolov5/yolov5-6.1/train.py", line 651, in
main(opt)
File "G:/yolov5/yolov5-6.1/train.py", line 544, in main
train(opt.hyp, opt, device, callbacks)
File "G:/yolov5/yolov5-6.1/train.py", line 129, in train
model = Model(cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device) # create
File "G:\yolov5\yolov5-6.1\models\yolo.py", line 112, in __init__
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
File "G:\yolov5\yolov5-6.1\models\yolo.py", line 126, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "G:\yolov5\yolov5-6.1\models\yolo.py", line 149, in _forward_once
x = m(x) # run
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "G:\yolov5\yolov5-6.1\models\common.py", line 139, in forward
return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), dim=1))
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "G:\yolov5\yolov5-6.1\models\common.py", line 47, in forward
return self.act(self.bn(self.conv(x)))
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\batchnorm.py", line 167, in forward
return F.batch_norm(
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\functional.py", line 2279, in batch_norm
_verify_batch_size(input.size())
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\functional.py", line 2247, in _verify_batch_size
raise ValueError("Expected more than 1 value per channel when training, got input size {}".format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1])Process finished with exit code 1
Traceback (most recent call last):
File "G:/yolov5/Yolov5_Magic-main/train.py", line 677, in
main(opt)
File "G:/yolov5/Yolov5_Magic-main/train.py", line 572, in main
train(opt.hyp, opt, device, callbacks)
File "G:/yolov5/Yolov5_Magic-main/train.py", line 124, in train
model = Model(cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device) # create
File "G:\yolov5\Yolov5_Magic-main\models\yolo.py", line 173, in __init__
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
File "G:\yolov5\Yolov5_Magic-main\models\yolo.py", line 190, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "G:\yolov5\Yolov5_Magic-main\models\yolo.py", line 233, in _forward_once
x = m(x) # run
File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "G:\yolov5\Yolov5_Magic-main\models\common.py", line 330, in forward
return torch.cat(x, self.d)
RuntimeError: torch.cat(): Sizes of tensors must match except in dimension 1. Got 16 and 32 in dimension 2 (The offending index is 1)Process finished with exit code 1
我在修改v5模型的时候,在添加一些模块的时候,一运行就出现了很多错误,刚开始去检查源码里面有没有问题,找了半天,也没找到,后来在模型文件周到了很多问题,比如一些添加了一些层,导致了一些层没有连接对,同理,当添加一些层后,检查一些层有没有连接对,就可以解决一些报错!!!下图是连接规则,同理,当你添加一些层后,需要去调整相应的变化部分。