question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Class conv_transpose2d is not found" when exporting a pruning-optimized model

See original GitHub issue

I tried pruning optimization (pruning only) for my detection model. I got following error when calling compression_ctrl.export_model()

  File "nncf_pytorch/nncf/compression_method_api.py", line 213, in export_model
    self.prepare_for_export()
  File "nncf_pytorch/nncf/pruning/filter_pruning/algo.py", line 204, in prepare_for_export
    model_pruner.prune_model()
  File "nncf_pytorch/nncf/pruning/export_helpers.py", line 392, in prune_model
    self.mask_propagation()
  File "nncf_pytorch/nncf/pruning/export_helpers.py", line 315, in mask_propagation
    cls = self.get_class_by_type_name(node_type)()
  File "nncf_pytorch/nncf/pruning/export_helpers.py", line 303, in get_class_by_type_name
    raise RuntimeError("Class {} is not found".format(type_name))
RuntimeError: Class conv_transpose2d is not found

Is it a bug or torch.nn.ConvTranspose2d not supported?

Pruning itself seems working judging from the training log of Mask zero %, PR, Filter PR columns printed by print_statistics function is above 0.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vshamporcommented, Oct 2, 2020
0reactions
nsk-labcommented, Oct 20, 2020

@vshampor @vanyalzr

Yes. I could export onnx without error. thx.

But the final pruning rate was low. my setting:

    "params": {
        "schedule": "baseline", // The type of scheduling to use for adjusting the target pruning level. Either `exponential`, `exponential_with_bias`,  or `baseline`, by default it is `baseline`"
        "pruning_init": 0.1, // Initial value of the pruning level applied to the model. 0.0 by default.
        "pruning_target": 0.4, // Target value of the pruning level for the model. 0.5 by default.
        "num_init_steps": 1, // Number of epochs for model pretraining before starting filter pruning. 0 by default.
        "pruning_steps": 4, // Number of epochs during which the pruning rate is increased from `pruning_init` to `pruning_target` value.
        "weight_importance": "L2", // The type of filter importance metric. Can be one of `L1`, `L2`, `geometric_median`. `L2` by default.
        "all_weights": false, // Whether to prune layers independently (choose filters with the smallest importance in each layer separately) or not. `False` by default.
        "prune_first_conv": false, // Whether to prune first Convolutional layers or not. First means that it is a convolutional layer such that there is a path from model input to this layer such that there are no other convolution operations on it. `False` by default.
        "prune_last_conv": false, // Whether to prune last Convolutional layers or not.  Last means that it is a Convolutional layer such that there is a path from this layer to the model output such that there are no other convolution operations on it. `False` by default.
        "prune_downsample_convs": false, // Whether to prune downsample Convolutional layers (with stride > 1) or not. `False` by default.
        "prune_batch_norms": false, // Whether to nullifies parameters of Batch Norm layer corresponds to zeroed filters of convolution corresponding to this Batch Norm. `False` by default.
        "zero_grad": true // Whether to setting gradients corresponding to zeroed filters to zero during training, `True` by default.
    },```

and the log at 5 epoch is

.
. (ommited)
.

+--------+--------+--------+--------+--------+--------+--------+-------+-------+
| XXXXXX | [64,   | [40,   | [64]   | [40]   | 147520 | 92200  | 0.375 | 0.375 |
| XXXX/Y | 256,   | 256,   |        |        |        |        |       |       |
| YYYYYY | 3, 3]  | 3, 3]  |        |        |        |        |       |       |
| YYY[ZZ |        |        |        |        |        |        |       |       |
| Z]/NNC |        |        |        |        |        |        |       |       |
| FConv2 |        |        |        |        |        |        |       |       |
| d[0]   |        |        |        |        |        |        |       |       |
+--------+--------+--------+--------+--------+--------+--------+-------+-------+
| XXXXXX | [64,   | [40,   | [64]   | [40]   | 147520 | 92200  | 0.375 | 0.375 |
| XXXX/Y | 256,   | 256,   |        |        |        |        |       |       |
| YYYYYY | 3, 3]  | 3, 3]  |        |        |        |        |       |       |
| YYY[ZZ |        |        |        |        |        |        |       |       |
| ]/NNCF |        |        |        |        |        |        |       |       |
| Conv2d |        |        |        |        |        |        |       |       |
| [0]    |        |        |        |        |        |        |       |       |
+--------+--------+--------+--------+--------+--------+--------+-------+-------+
INFO:nncf:Final Model Pruning Rate = 0.165
INFO:nncf:Total MAC pruning level = 0.124

0.165 is much lower than pruning target 0.4 Is it due to uncompressed ConvTranspose2D layer?

if so, i really want the support of pruning ConvTranspose2D

Read more comments on GitHub >

github_iconTop Results From Across the Web

ConvTranspose2d — PyTorch 1.13 documentation
Applies a 2D transposed convolution operator over an input image composed of several input planes. This module can be seen as the gradient...
Read more >
upsample_bilinear2d issue when exporting to onnx #22906
I can not export from PyTorch to ONNX using the upsample operator with torch version 1.3.1, onnx version 1.5.0. MINIMUM CODE TO REPRODUCE:....
Read more >
What output_padding does in nn.ConvTranspose2d?
Output padding helps pytorch to determine 7x7 or 8x8 output with output_padding parameter. Note that, it doesn't pad zeros or anything to output ......
Read more >
The nncf from openvinotoolkit - GithubHelp
I did not find related information/example yet. it seems nncf does not ... "Class conv_transpose2d is not found" when exporting a pruning-optimized model....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found