I can't load model correctly
dddZhao opened this issue · 1 comments
dddZhao commented
I have trained and saved model with my dataset, printed as follow:
model saved: ./saved_models\fixmatch\latest_model.pth
model saved: ./saved_models\fixmatch\model_best.pth
But when I load the model again, it has a problem:
import torch
trainer = torch.load("./saved_models/fixmatch/model_best.pth")
y_pred, y_logits = trainer.predict(eval_loader)
AttributeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 y_pred, y_logits = trainer.predict(eval_loader)
AttributeError: 'dict' object has no attribute 'predict'
I see that this model is saved with torch, but it cannot be read with torch correctly. Could you help me?
dddZhao commented
I load the model with :
trainer.algorithm.load_model("./saved_models/fixmatch/model_best.pth")