pytorch-slimming
pytorch-slimming copied to clipboard
model size after finetuning
@foolwood
I noticed model size after finetuning is the same as the original model size. Shouldn't the size be the same as the pruned model?
Thanks,
I meet the same problem as yours, and I solved it by clearing the pycache, and I hope it will help you~
I can get this, the pruned model size is 9.3M which is not 2.2M? @angelamin @kaishijeng is it same as your model?

emmm, after I run 'python main.py -sr --s 0.0001', my checkpoint.pth.tar is 153M... Can you help me? Thanks.
And it didn't save model_best.pth.tar...
I check it, because of pytorch0.4, after test,type(prec1) is Tensor, so change it to type int. But models are still 153M....
@MrLinNing Hello, I only change dataset's path to own Cifar10, how do you save so small model? Thanks for your help.
Parameters are 20M, so model size should be (20x1000000x32)/(1024x1024x8)=76.29M soga
@RichardMrLu : how did you run the script with version 0.4? Can you share your changes?
@Coderx7 def test(): model.eval() test_loss = 0 correct = 0 for data, target in test_loader: if args.cuda: data, target = data.cuda(), target.cuda() data, target = Variable(data, volatile=True), Variable(target) output = model(data) test_loss += F.cross_entropy(output, target, size_average=False).data[0] # sum up batch loss pred = output.data.max(1, keepdim=True)[1] # get the index of the max log-probability correct += pred.eq(target.data.view_as(pred)).cpu().sum()
test_loss /= len(test_loader.dataset)
print('\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.1f}%)\n'.format(
test_loss, correct, len(test_loader.dataset),
100. * correct / len(test_loader.dataset)))
return 100. * correct / len(test_loader.dataset)
def save_checkpoint(state, is_best, filename='checkpoint.pth.tar'): torch.save(state, filename) if is_best: shutil.copyfile(filename, 'model_best.pth.tar')
best_prec1 = 0. print(model) for epoch in range(args.start_epoch, args.epochs): if epoch in [args.epochs0.5, args.epochs0.75]: for param_group in optimizer.param_groups: param_group['lr'] *= 0.1 train(epoch) prec1 = test() is_best = int(prec1) > best_prec1 best_prec1 = max(int(prec1), int(best_prec1)) save_checkpoint({ 'epoch': epoch + 1, 'state_dict': model.state_dict(), 'best_prec1': best_prec1, 'optimizer': optimizer.state_dict(), }, is_best)
@RichardMrLu My original model is 160M . Why our models such big with only 20M parameters?