SpursLipu / YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone

YOLO ModelCompression MultidatasetTraining
GNU General Public License v3.0
444 stars 136 forks source link

RuntimeError: Sizes of tensors must match except in dimension 2. #89

Open indersingh17188 opened 3 years ago

indersingh17188 commented 3 years ago

Hello, I have successfully finished the following steps:

  1. Normal training using 1000 images from coco-2014 dataset with command: python3 train.py --data data/coco2014.data --batch-size 16 -pt --weights yolov4.weights --cfg cfg/yolov4/yolov4.cfg

  2. After this I obtained initial weights last.pt and using then I have successfully finished sparsity training with command: python train.py --data data/coco2014.data -pt --weights weights/last.pt --batch-size 4 --cfg cfg/yolov4/yolov4.cfg --epochs 200 -sr --s 0.001 --prune 0

  3. However, in the final pruning stage I am stuck while testing the final model step. The compactmodel2 is unable to go through eval_model function as when the tensors go through test.py they throw following error:

    RuntimeError: Sizes of tensors must match except in dimension 2. Got 44and 88 (The offending index is 0).

I will really appreciate for any solutions. Thanks in advance.

The command I use to run pruning is: _python layer_channel_regularprune.py --data data/coco2014.data --weights weights/last.pt --cfg cfg/yolov4/yolov4.cfg --percent 0.5 --img-size 608

SpursLipu commented 3 years ago

I am sorry tell you layer_channell_prune method is unsupported right now, you can use layer prune at first, I will fix this bug resently.

abishk12 commented 3 years ago

@SpursLipu thank you replying. I had the same issue.. so I tried python layer_prune.py --data data/coco2014.data --weights weights/Yolov4_sparsity_prune0.pt --cfg cfg/yolov4/yolov4.cfg and pruning completed.. +------------+----------+----------+ | Metric | Before | After | +------------+----------+----------+ | mAP | 0.005023 | 0.000000 | | Parameters | 64363101 | 56653917 | | Inference | 0.0227 | 0.0196 | +------------+----------+----------+ Config file has been saved: cfg/prune_8_shortcut_yolov4/prune_8_shortcut_yolov4.cfg Compact model has been saved: weights/prune_8_shortcut_Yolov4_sparsity_prune0.weights

The mAP is 0 and there are no detections happening did I miss something?

Nithyan20 commented 3 years ago

I am sorry tell you layer_channell_prune method is unsupported right now, you can use layer prune at first, I will fix this bug resently.

RuntimeError: Sizes of tensors must match except in dimension 2. Got 58 and 106 (The offending index is 0). Still the error comes when I run the layer_channel_prune.py. Is this bug fixed?

I will really appreciate for any solutions.

lvy1999s commented 1 year ago

很抱歉告诉您layer_channell_prune方法现在不受支持,您可以先使用图层修剪,我会怨恨地修复此错误。

运行时错误:张量的大小必须匹配,维度 2 除外。得到 58 和 106(违规指数为 0)。当我运行layer_channel_prune.py时,仍然会出现错误。这个错误修复了吗?

我将非常感谢任何解决方案。

I am sorry tell you layer_channell_prune method is unsupported right now, you can use layer prune at first, I will fix this bug resently.

RuntimeError: Sizes of tensors must match except in dimension 2. Got 58 and 106 (The offending index is 0). Still the error comes when I run the layer_channel_prune.py. Is this bug fixed?

I will really appreciate for any solutions. Hi,Did you fixed this bug?