We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I try to print the layer and the shape of the weights it is quite ambiguous!
print(pruned_model.conv1, pruned_model.conv1.weight.shape (Conv2d(3, 4, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False), torch.Size([64, 3, 7, 7]))
The complete flow can be found below:
pruned_model = copy.deepcopy(resnet) import torch_pruning as tp for layer in conv_list: pruned_model_device = next(iter(pruned_model.parameters())).device DG = tp.DependencyGraph().build_dependency(pruned_model, example_inputs=torch.randn(1,3,32,32).to(pruned_model_device)) # 2. Group coupled layers for model.conv1 indices = mapped_layers['layer_pruning_indices'][layer] indices_to_prune = indices[:int(len(indices)*0.95)] layer_name = layer.replace('model','pruned_model') layer_for_pruning = eval(layer_name) # if(isinstance(layer,nn.Conv2d)): group = DG.get_pruning_group( layer_for_pruning , tp.prune_conv_out_channels, idxs=indices_to_prune) if DG.check_pruning_group(group): # avoid full pruning, i.e., channels=0. print(layer_name) print("Layer:",eval(layer_name),"Shape:",layer_for_pruning.weight.shape,"Indices:",len(indices_to_prune)) group.prune() pruned_model.zero_grad() print("Layer:",eval(layer_name),"Shape:",layer_for_pruning.weight.shape,"Indices:",len(indices_to_prune)) # _ = pruned_model(torch.randn(1,3,32,32)) break pruned_model.eval() pruned_model.zero_grad() print(pruned_model.conv1.weight.shape)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I try to print the layer and the shape of the weights it is quite ambiguous!
The complete flow can be found below:
The text was updated successfully, but these errors were encountered: