device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# create model
model = create_model(num_classes=5).to(device)
# load model weights
model_weight_path = "./weights/model-49.pth"
torch.save(model.state_dict(),model_weight_path)
model.load_state_dict(torch.load(model_weight_path, map_location=device))
model.eval()
参考下这个
你第六行在干吗?
先用model的初始值覆盖掉model-49.pth?然后从model-49.pth里面加载权重?那model的权重不还是初始值?那你训练的意义何在