VainF / Torch-Pruning

[CVPR 2023] DepGraph: Towards Any Structural Pruning
https://arxiv.org/abs/2301.12900
MIT License
2.7k stars 332 forks source link

IndexError: index 192 is out of bounds for dimension 0 with size 192 #263

Open mariosconsta opened 1 year ago

mariosconsta commented 1 year ago

I am using this architecture (HR-Net) and below is my code snippet when I went to test prunning:

model = get_seg_model(train=True).eval()
imp =  tp.importance.MagnitudeImportance() #whats this

example_inputs = torch.randn(1, 3, 512, 512)

pruner = tp.pruner.MetaPruner( # We can always choose MetaPruner if sparse training is not required.
    model,
    example_inputs,
    importance=imp,
    ch_sparsity=0.5, # remove 50% channels, ResNet18 = {64, 128, 256, 512} => ResNet18_Half = {32, 64, 128, 256}
    # ch_sparsity_dict = {model.conv1: 0.2, model.layer2: 0.8}, # customized sparsity for layers or blocks
    ignored_layers=None,
)

base_macs, base_nparams = tp.utils.count_ops_and_params(model, example_inputs)
pruner.step()

Then I get this error: image

Any tips?

wujianfei5201314 commented 1 year ago

Hello, is the problem resolved?

Minspeech commented 11 months ago

I also encountered the same problem, have you solved it?

mariosconsta commented 11 months ago

Hello, is the problem resolved?

I also encountered the same problem, have you solved it?

Nope, I didn't solve it.