SpursLipu / YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone

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

mat1 dim 1 must match mat2 dim 0 #93

Open mate-hegedus opened 3 years ago

mate-hegedus commented 3 years ago

while trying to prune after sparse training:

sudo python3 regular_prune.py --cfg cfg/yolo-fastest-xl-test.cfg --data data/obj-boar.data --weights weights/last.pt --percent 0.95 --img-size 1280 Namespace(cfg='cfg/yolo-fastest-xl-test.cfg', data='data/obj-boar.data', img_size=1280, percent=0.95, weights='weights/last.pt') Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Warning: Unrecognized Layer Type: dropout Model Summary: 253 layers, 834324 parameters, 834324 gradients Caching labels (213 found, 0 missing, 558 empty, 0 duplicate, for 771 images): 100%|██████| 771/771 [00:00<00:00, 25955.60it/s] Class Images Targets P R mAP@0.5 F1: 0%| | 0/49 [00:00<?, ?it/s]/home/xxx/Downloads/yolov4comp3/test.py:152: UserWarning: This overload of nonzero is deprecated: nonzero() Consider using one of the following signatures instead: nonzero(*, bool as_tuple) (Triggered internally at /pytorch/torch/csrc/utils/python_arg_parser.cpp:882.) ti = (cls == tcls_tensor).nonzero().view(-1) # prediction indices Class Images Targets P R mAP@0.5 F1: 100%|████████| 49/49 [00:14<00:00, 3.38it/s] all 771 442 0.615 0.686 0.684 0.648 Threshold should be less than 0.0000. The corresponding prune ratio is 0.651. Channels with Gamma value less than 0.0661 are pruned! Caching labels (213 found, 0 missing, 558 empty, 0 duplicate, for 771 images): 100%|██████| 771/771 [00:00<00:00, 26787.01it/s] Class Images Targets P R mAP@0.5 F1: 100%|████████| 49/49 [00:13<00:00, 3.55it/s] all 771 442 0 0 0 0 Number of channels has been reduced from 12184 to 1032 Prune ratio: 0.915 mAP of the pruned model is 0.0000 layer index: 0 total channel: 16 remaining channel: 8 layer index: 1 total channel: 16 remaining channel: 16 layer index: 2 total channel: 16 remaining channel: 8 layer index: 4 total channel: 16 remaining channel: 8 layer index: 5 total channel: 16 remaining channel: 8 layer index: 6 total channel: 8 remaining channel: 8 layer index: 9 total channel: 48 remaining channel: 16 layer index: 10 total channel: 48 remaining channel: 24 layer index: 12 total channel: 64 remaining channel: 8 layer index: 13 total channel: 64 remaining channel: 8 layer index: 14 total channel: 16 remaining channel: 8 layer index: 17 total channel: 64 remaining channel: 8 layer index: 18 total channel: 64 remaining channel: 8 layer index: 19 total channel: 16 remaining channel: 8 layer index: 22 total channel: 64 remaining channel: 48 layer index: 23 total channel: 64 remaining channel: 24 layer index: 25 total channel: 96 remaining channel: 8 layer index: 26 total channel: 96 remaining channel: 8 layer index: 27 total channel: 16 remaining channel: 8 layer index: 30 total channel: 96 remaining channel: 8 layer index: 31 total channel: 96 remaining channel: 8 layer index: 32 total channel: 16 remaining channel: 8 layer index: 35 total channel: 96 remaining channel: 16 layer index: 36 total channel: 96 remaining channel: 40 layer index: 38 total channel: 192 remaining channel: 8 layer index: 39 total channel: 192 remaining channel: 8 layer index: 40 total channel: 32 remaining channel: 8 layer index: 43 total channel: 192 remaining channel: 8 layer index: 44 total channel: 192 remaining channel: 8 layer index: 45 total channel: 32 remaining channel: 8 layer index: 48 total channel: 192 remaining channel: 8 layer index: 49 total channel: 192 remaining channel: 8 layer index: 50 total channel: 32 remaining channel: 8 layer index: 53 total channel: 192 remaining channel: 16 layer index: 54 total channel: 192 remaining channel: 80 layer index: 55 total channel: 32 remaining channel: 16 layer index: 58 total channel: 192 remaining channel: 8 layer index: 59 total channel: 192 remaining channel: 40 layer index: 61 total channel: 272 remaining channel: 8 layer index: 62 total channel: 272 remaining channel: 8 layer index: 63 total channel: 48 remaining channel: 8 layer index: 66 total channel: 272 remaining channel: 8 layer index: 67 total channel: 272 remaining channel: 16 layer index: 68 total channel: 48 remaining channel: 16 layer index: 71 total channel: 272 remaining channel: 8 layer index: 72 total channel: 272 remaining channel: 8 layer index: 73 total channel: 48 remaining channel: 8 layer index: 76 total channel: 272 remaining channel: 8 layer index: 77 total channel: 272 remaining channel: 8 layer index: 78 total channel: 48 remaining channel: 8 layer index: 81 total channel: 272 remaining channel: 16 layer index: 82 total channel: 272 remaining channel: 32 layer index: 84 total channel: 448 remaining channel: 8 layer index: 85 total channel: 448 remaining channel: 8 layer index: 86 total channel: 96 remaining channel: 8 layer index: 89 total channel: 448 remaining channel: 8 layer index: 90 total channel: 448 remaining channel: 16 layer index: 91 total channel: 96 remaining channel: 8 layer index: 94 total channel: 448 remaining channel: 8 layer index: 95 total channel: 448 remaining channel: 16 layer index: 96 total channel: 96 remaining channel: 8 layer index: 99 total channel: 448 remaining channel: 8 layer index: 100 total channel: 448 remaining channel: 8 layer index: 101 total channel: 96 remaining channel: 8 layer index: 104 total channel: 448 remaining channel: 8 layer index: 105 total channel: 448 remaining channel: 8 layer index: 106 total channel: 96 remaining channel: 16 layer index: 109 total channel: 96 remaining channel: 8 layer index: 110 total channel: 96 remaining channel: 16 layer index: 111 total channel: 128 remaining channel: 8 layer index: 112 total channel: 128 remaining channel: 24 layer index: 113 total channel: 128 remaining channel: 32 layer index: 119 total channel: 96 remaining channel: 8 layer index: 120 total channel: 96 remaining channel: 16 layer index: 121 total channel: 96 remaining channel: 8 layer index: 122 total channel: 96 remaining channel: 24 layer index: 123 total channel: 96 remaining channel: 32 Prune channels: 11152 Prune ratio: 0.899 Traceback (most recent call last): File "regular_prune.py", line 207, in pruned_model = prune_model_keep_size(model, prune_idx, CBL_idx, CBLidx2mask) File "/home/xxx/Downloads/yolov4comp3/utils/prune_utils.py", line 292, in prune_model_keep_size update_activation(i, pruned_model, activation, CBL_idx) File "/home/xxx/Downloads/yolov4comp3/utils/prune_utils.py", line 403, in update_activation offset = conv_sum.matmul(activation.reshape(-1, 1)).reshape(-1) RuntimeError: mat1 dim 1 must match mat2 dim 0