tanluren / yolov3-channel-and-layer-pruning

yolov3 yolov4 channel and layer pruning, Knowledge Distillation 层剪枝,通道剪枝,知识蒸馏
Apache License 2.0
1.5k stars 446 forks source link

Changing max pooling kernel size #159

Open areberoto opened 3 years ago

areberoto commented 3 years ago

Hello, I am trying to use this repository to prune my modified YOLOv4 model, but I am having trouble with the kernel sizes of the max pooling layers. They are of size 5, 9 and 13 (lines 771 - 792 of cfg file), and I need them to be 5, 6 and 8 respectively. When I change them I get the following error:

Traceback (most recent call last):
  File "/home/alberto/yolov3-channel-and-layer-pruning/models.py", line 247, in forward
    x = torch.cat([layer_outputs[i] for i in layers], 1)
RuntimeError: Sizes of tensors must match except in dimension 2. Got 16 and 15 (The offending index is 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train.py", line 542, in <module>
    train()  # train normally
  File "train.py", line 348, in train
    pred = model(imgs)
  File "/home/alberto/anaconda3/envs/pruning_yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/alberto/yolov3-channel-and-layer-pruning/models.py", line 250, in forward
    x = torch.cat([layer_outputs[i] for i in layers], 1)
RuntimeError: Sizes of tensors must match except in dimension 2. Got 16 and 15 (The offending index is 0)

Can someone help me with this issue? I don't understand why it cannot support these kernel sizes directly. Thanks