Hahn-Schickard / Automatic-Structured-Pruning

We have implemented a framework that supports developers to structured prune neural networks of Tensorflow Models
Apache License 2.0
26 stars 4 forks source link

Towards Supporting Skip Connections #26

Closed vse-motec closed 2 years ago

vse-motec commented 2 years ago

I am currently working an adding support to prune networks with skip connections. If you are interested, I can provide all steps towards this goal as individual pull requests (as soon as I have them).

The first step is checking each layers's parent during filter / node deletion in the functions "delete_filter" and "delete_dense_neuron". So far, these functions assume that a layer at index (i+1) has its parent at index i. However, since this is not the case for skip connections, we have to add parent layer checking.

This additional check should not affect your code in a negative way. I can provide the corresponding pull request for you to run your tests.

konegen commented 2 years ago

Hi, this sounds very interesting, If you want to be a part of the development, we would be very happy.

Kind regards Daniel

vse-motec commented 2 years ago

Hello, yes, I would like to contribute. Short update: there has been a delay because I was working on an outdated version of this repository. Need some more testing that the merge went smoothly. Get back to this next week. Best regards, Viktor

vse-motec commented 2 years ago

Hello again,

I have implemented a preliminary version that allows handling networks with skip connections (but not the connections itself, yet). In more detail:

However, all conv layers that are not last before branch or first after merge can be pruned. This allows the software to handle networks with skip connections without failing. I have tested it with a (functional) Yolov3 model and with the (sequential) model that you provide in the Jupyther notebook - both work fine.

Please review my changes and give me some feedback. I suggest for now to create a separate experimental branch and not yet merge into main. Also the code formatting might not be completely in your style. I will improve this in a future pull request.

Best regards Viktor

konegen commented 2 years ago

Hi and sorry for the late answer. Thank you very much for your work. We can also discuss it in a call.

Best regards Daniel

vse-motec commented 2 years ago

Hi all, I have now added the missing functionality to prune all conv layers. So far only tested with the provided Jupyter Notebook (sequential model) and with YoloV3 (functional model). Best regards Viktor

konegen commented 2 years ago

Hey, thank you very much for your work and the second pull request.

Best regards Daniel