Torch-Pruning icon indicating copy to clipboard operation
Torch-Pruning copied to clipboard

after load a pruned model,how to test the pruned model?

Open henbucuoshanghai opened this issue 3 years ago • 1 comments

load a pruned model model = torch.load('model.pth') # no load_state_dict

henbucuoshanghai avatar Feb 20 '21 12:02 henbucuoshanghai

Hi @henbucuoshanghai, The inference (for evaluation or testing) is pretty straightforward I guess, you could check this link or follow my simple step below.

Simply do this should work for your model.

# load a pruned model
model = torch.load('model.pth') # no load_state_dict
model.eval()
device = torch.device('cuda:0') # torch.device('cuda') for Windows
model.to(device)
# model.cuda() also works in Windows 
input = torch.rand((1,3,224,224)) # or your desired input
input.to(device)
# input.cuda() also works in Windows

with torch.no_grad():
    out = model(input)

Voila, that's it!

briliantnugraha avatar Mar 04 '21 09:03 briliantnugraha