我有一個 CNN 模型,我想保存它并將其加載到不同的選項卡中進行預測。但是我很困惑 model.evulotion 部分是否包含在我將保存的部分中。而且我不知道使用 Model.checkpoint 或 model.save 保存和加載是否會更好。有沒有人有想法?先感謝您
我在使用它們時處于兩難境地,所以我已經使用它了。
uj5u.com熱心網友回復:
Using model.eval()just 告訴 PyTorch 模型使用平均值進行批量標準化,并停用 dropout 層。您可以在不使用的情況下保存模型,model.eval()因為它不會影響性能。保存模型時,優先保存模型的狀態字典。這可以如圖所示完成:
#declare class of model here
model = NeuralNetwork()
#add training code below
...
#saving model, the model will be saved at the intermediateWeightPath location
intermediateWeightPath = "./bestmodel.pth"
torch.save(model.state_dict(), intermediateWeightPath)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/525350.html
上一篇:為什么User.FindFirstValue(claimtypes.nameidentifier)總是回傳null?
下一篇:具體結構的模擬特征實作
