In my model, there is a fixed and pretrained sub-module which I don’t want to store it in state_dict() for smaller checkpoint size.
class MyModel(nn.Module):
    def __init__(self, ref_model):
        super().__init__()
        self.fc = nn.Linear(3,4)  # trainable parameters
        self.ref_m = ref_model    # fixed parameters
        for m in self.ref_m.parameters():
            m.requires_grad=False

ref_model=...
model = MyModel(ref_model)
# how to exclude ref_model from state_dict()?
checkpoint = model.state_dict()