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

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

Open mariosconsta opened this issue 2 years ago • 3 comments

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?

mariosconsta avatar Sep 28 '23 08:09 mariosconsta

Hello, is the problem resolved?

wujianfei5201314 avatar Oct 30 '23 08:10 wujianfei5201314

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

Minspeech avatar Nov 27 '23 08:11 Minspeech

Hello, is the problem resolved?

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

Nope, I didn't solve it.

mariosconsta avatar Nov 28 '23 20:11 mariosconsta