How to load weight of part of filters for each layer from pertained model?

I have a resnet18 model that the filters of each layer are half of the original ImageNet resnet18 model. Now, I want to load the pertained weight of ImageNet resnet18 model to my own resnet18. How can I load it?

By “half” do you mean the number of filters or their spatial size?
You could try to load the weights manually:

with torch.no_grad():
    new_model.conv.weight = old_model.conv.weight[:3]  # assuming old model used 6 filters
    # or for half the spatial size
    new_model.conv.weight = old_model.conv.weight[:, :, :2, :2]