Hello everyone,
I have a model and I prune it so that its inference time gets shorter. Pruned model doesn’t change the general structure (same sequence of conv, batchnorm, relu) but dimensions for convolutional layers, batch normalization change due to pruning. When my model is pruned, I save it in the following way:
torch.save(model.state_dict(), "model_pruned")

Once my model is pruned and saved, I try to load it into my old model in this way:
network = OldNet().cuda()
dest = 'path/to/pruned_network'
network.load_state_dict(torch.load(dest))
network = network.eval()

This gives then a Runtime Error:
RuntimeError: Error(s) in loading state_dict for OldNet:
	size mismatch for features.0.weight: copying a param with shape torch.Size([28, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([32, 1, 5, 5]).
	size mismatch for features.0.bias: copying a param with shape torch.Size([28]) from checkpoint, the shape in current model is torch.Size([32]).

I understand why I encounter this error but I don’t know how to load my new model for inference.
Any help would be really appreciated! Thank you!