How to use prune for CNNs?

2 ビュー (過去 30 日間)
Nour Mohamed
Nour Mohamed 2021 年 1 月 12 日
回答済み: Maksym Tymchenko 2023 年 11 月 2 日
I want to prune pretrained CNNs by certain rates (0.1-0.9). But when I try to use the prune function I get the following error:
Check for missing argument or incorrect argument data type in call to function 'prune'.
How can I use this function for CNNs (in this case resnet18) and is there a way to specify the pruning rate?
Thank you,
  1 件のコメント
Shaw
Shaw 2021 年 11 月 3 日
Did you get any solution for this?

サインインしてコメントする。

回答 (2 件)

Nitin Kapgate
Nitin Kapgate 2021 年 1 月 15 日
Currently the "prune" function does not provide the functionality to prune the network at specified pruninng rate.
The prune function removes zero-sized inputs, layers, and outputs from a network.
This leaves a network which may have fewer inputs and outputs, but which implements the same operations, as zero-sized inputs and outputs do not convey any information.
  1 件のコメント
Nour Mohamed
Nour Mohamed 2021 年 1 月 18 日
Thank you for your answer. But why can't I use it with CNNs? Why do I get that error?

サインインしてコメントする。


Maksym Tymchenko
Maksym Tymchenko 2023 年 11 月 2 日
In MATLAB, you can compress deep neural networks by using the Deep Learning Model Quantization Library, which is a free Add-On to the Deep Learning Toolbox.
This library contains a set of different functions that allow you to compress your deep learning network.
You mentioned pruning, this is a type of structural compression where the least important weights in the network are discarded making the network smaller. The "prune" function that you mentioned only accepts "shallow neural networks" as input. That is the reason why it did not work on resnet18. If you want to perform structural compression on a deep neural network like resnet18, you can use either:
Both of these functions work only on dlnetwork objects, so you might need to convert your network to that form in order to use them. For an example of how to prune convolutional filters in a CNN see:

カテゴリ

Help Center および File ExchangeRecognition, Object Detection, and Semantic Segmentation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by