Classes have attributes (anything you call by self.whatever).
Pytorch is coded such that when you set
self.anything= X
It inspects that X. If it’s a nn.Module or a tensor (a layer or a pytorch tensor) it keeps track of it.
Then when you save the model, pytorch iterates over all the layers nor you defined.
This bug can be generated if
When you created an instance of the class
model = Model(model=resnet, pool=gmp) <<<< model is an instance of the class Model
gmp (X in my example) is a different thing from a nn.Module or a tensor.
The second time, when you want to load the model X is a nn.Module or a tensor.
Then it “misses” that.
So in your case it seems pool is a nn.Module but there is something defined inside which is missing. Either due to what i explained or due to some if conditional statement which is skipping it.