Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.48k stars 1.49k forks source link

Sizes of tensors must match except in dimension 1. Got 13 and 14 in dimension 2 (The offending index is 1) #366

Open snop222 opened 3 years ago

snop222 commented 3 years ago

I try to train with my simple dataset. But got the error message. How can i to fix the problem? I trained dataset in Windows 10 with CPU.

`log file path:log\log_2021-01-16_21-33-33.txt 2021-01-16 21:33:33,388 train.py[line:614] INFO: Using device cpu convalution havn't activate linear convalution havn't activate linear convalution havn't activate linear 2021-01-16 21:33:34,123 train.py[line:313] INFO: Starting training: Epochs: 300 Batch size: 4 Subdivisions: 1 Learning rate: 0.001 Training size: 160 Validation size: 40 Checkpoints: True Device: cpu Images size: 200 Optimizer: adam Dataset classes: 4 Train label path:e:\MyApps\Deep\YOLOv4\data\train.txt Pretrained:

Epoch 1/300: 0%| | 0/160 [00:13<?, ?img/s] Traceback (most recent call last): File "e:/MyApps/Deep/YOLOv4/train.py", line 626, in train(model=model, File "e:/MyApps/Deep/YOLOv4/train.py", line 380, in train bboxes_pred = model(images) File "D:\Anaconda3\envs\YOLOv4\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "e:\MyApps\Deep\YOLOv4\tool\darknet2pytorch.py", line 179, in forward x = torch.cat((x1, x2), 1) RuntimeError: Sizes of tensors must match except in dimension 1. Got 13 and 14 in dimension 2 (The offending index is 1)`

NJUEELJN commented 3 years ago

Hi , may I ask if you have solved the problem? I met same issue with you, and I doubt the cause is dataset classes, can we discuss further?

snop222 commented 3 years ago

Hi , may I ask if you have solved the problem? I met same issue with you, and I doubt the cause is dataset classes, can we discuss further?

Sorry, I have changed to use YOLOv5....

robot-lfr commented 2 years ago

I try to train with my simple dataset. But got the error message. How can i to fix the problem? I trained dataset in Windows 10 with CPU.

`log file path:log\log_2021-01-16_21-33-33.txt 2021-01-16 21:33:33,388 train.py[line:614] INFO: Using device cpu convalution havn't activate linear convalution havn't activate linear convalution havn't activate linear 2021-01-16 21:33:34,123 train.py[line:313] INFO: Starting training: Epochs: 300 Batch size: 4 Subdivisions: 1 Learning rate: 0.001 Training size: 160 Validation size: 40 Checkpoints: True Device: cpu Images size: 200 Optimizer: adam Dataset classes: 4 Train label path:e:\MyApps\Deep\YOLOv4\data\train.txt Pretrained:

Epoch 1/300: 0%| | 0/160 [00:13<?, ?img/s] Traceback (most recent call last): File "e:/MyApps/Deep/YOLOv4/train.py", line 626, in train(model=model, File "e:/MyApps/Deep/YOLOv4/train.py", line 380, in train bboxes_pred = model(images) File "D:\Anaconda3\envs\YOLOv4\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "e:\MyApps\Deep\YOLOv4\tool\darknet2pytorch.py", line 179, in forward x = torch.cat((x1, x2), 1) RuntimeError: Sizes of tensors must match except in dimension 1. Got 13 and 14 in dimension 2 (The offending index is 1)`

Maybe because your input size is 200, while 200 / 32 is not an integer, and It's OK for me to use 320 input size。