IndexError: index 512 is out of bounds for dimension 0 with size 512
imp = tp.importance.MagnitudeImportance(p=1) example_inputs = torch.randn(1, 3, 224, 224) ignored_layers = [] for m in model.modules(): if isinstance(m, torch.nn.Linear) and m.out_features == args.nb_classes: ignored_layers.append(m) # DO NOT prune the final classifier!
iterative_steps = 1 #
pruner = tp.pruner.MagnitudePruner(
model,
example_inputs, #
importance=imp, #
iterative_steps=iterative_steps, #
ch_sparsity=0.5, #
ignored_layers=ignored_layers, #
)
4. Pruning-Finetuning的循环
base_macs, base_nparams = tp.utils.count_ops_and_params(model, example_inputs)
for i in range(iterative_steps):
# pruner.step()
for group in pruner.step(interactive=True): # Warning: groups must be handled sequentially. Do not keep them as a list.
print(group.details()) #
#
group.prune()
macs, nparams = tp.utils.count_ops_and_params(model, example_inputs)
Hello @812985728, could you provide the model name in your case?
hello, the model is designed by me, which based on deit , the problem occurs in MLP module。
812985728 @.***
------------------ 原始邮件 ------------------ 发件人: "Rémi @.>; 发送时间: 2024年2月23日(星期五) 下午2:31 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [VainF/Torch-Pruning] IndexError: index 512 is out of bounds for dimension 0 with size 512 (Issue #342)
Hello @812985728, could you provide the model name in your case?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>