karpathy / ng-video-lecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to save, Load and Finetune the model

Lokeshwaran-M opened this issue · comments

Model :

model = LanguageModel()

To Save

with open('model.pkl', 'wb') as f:
    pickle.dump(model, f)

To Load :

with open('model.pkl', 'rb') as f:
    model = pickle.load(f)
m = model.to(device)

You can also use: torch.save() and torch.load() for the model and/or optimizer's state_dict()