You are right I used torch.save(model),previously. But now I did the following:-
I need to save 3 parameters as- epoch,best_acc and the model itself.
I did it this way:-
state={‘net’:model, ‘epoch’:epoch,‘accuracy’:best_acc}
torch.save(state,PATH)
but when I’m loading using    checkpoint=torch.load(saved_path),
I am getting an Attribute  Error as Can’t get attribute ‘CifarVggnet’ on <module ‘ main ’ from ‘Checking.py’>
Here, CifarVggnet is the name of the model that I’m saving. And I’m loading it from Checking.py.
To avoid this error then I defined the model as:
class CifarVggnet(nn.Module):
def init(self):
super(CifarVggnet,self).init()
I defined this in my Checking.py from where I’m loading the file.
Now I can load the attributes of the saved model as checkpoint[‘net’],checkpoint[‘epoch’] and checkpoint[‘accuracy’]. I printed then and they are correctly printing.
But now I got a new problem:-
The problem is that I can print the model. But I cannot access the feature part of the model.
i.e., when I do print(net.features), the error I am getting is:
Traceback (most recent call last):

File “Checking.py”, line 27, in *
print(net.features)*
File “/home/anaconda2/envs/pytorch_v36/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 539, in getattr*
type(self).name, name))*
AttributeError: ‘CifarVggnet’ object has no attribute ‘features’


How do I solve this now…Am I doing it the wrong way?