Torch-Pruning icon indicating copy to clipboard operation
Torch-Pruning copied to clipboard

Why are the layers in ignored_layers still pruned?

Open AFallDay opened this issue 1 year ago • 5 comments

Here is my code and the results of running it. image image

The layers printed out by ignored_layers are Detcet's layers, but it is still pruned. Here's the number of channels after pruning. image How can I change so that it doesn't prune the Detect layer?

AFallDay avatar Feb 22 '24 07:02 AFallDay

Hi @AFallDay, in v1.3 we only ignore the output of a layer and its input dim will be pruned due to its dependency to previous layers. If you need a more fine-grained ignore_list, please refer to the v1.4 branch, which supports ignored_layer_outputs and ignored_layer_inputs.

An example of ignored_layer_inputs can be found here

VainF avatar Feb 23 '24 12:02 VainF

Hi @AFallDay, in v1.3 we only ignore the output of a layer and its input dim will be pruned due to its dependency to previous layers. If you need a more fine-grained ignore_list, please refer to the v1.4 branch, which supports ignored_layer_outputs and ignored_layer_inputs.

An example of ignored_layer_inputs can be found here

thanks @VainF ,I've looked at the example in v1.4 but there are input and output channels that need to be defined, and they seem to be a little complicated to modify, do you have an easier way to modify it? image

AFallDay avatar Feb 24 '24 08:02 AFallDay

Yes, we can manually add the preceding layers to the ignored_layers.

VainF avatar Feb 24 '24 09:02 VainF

Yes, we can manually add the preceding layers to the ignored_layers.

How do I add yolov5s‘layers to the ignored_layers? I'm not very good at it. Could you please answer?

AFallDay avatar Feb 24 '24 09:02 AFallDay

You can manually find the coupled layers for the convs in Detect and just append them into the ignored_layers. I think v1.4 is easier to use. Just adding the line ignroed_layer_inputs=[ detect[0], detect[1], detect[2], detect[3] ] should work.

VainF avatar Feb 24 '24 10:02 VainF