saving model in pytorch code example

Example 1: pytorch save model

Saving:
	torch.save(model, PATH)


Loading: 
	model = torch.load(PATH)
	model.eval()
    
A common PyTorch convention is to save models using either a .pt or .pth file extension.

Example 2: pytorch model

class Model(nn.Module):
    
    
    def __init__(self, in_features=4, h1=8, h2=9, out_features=3):
        # how many layers?
        super().__init__()
        self.fc1 = nn.Linear(in_features, h1)
        self.fc2 = nn.Linear(h1, h2)
        self.out = nn.Linear(h2, out_features)
    
    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.out(x)
        
        return x