Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model size after finetuning #1

Open
kaishijeng opened this issue Feb 25, 2018 · 10 comments
Open

model size after finetuning #1

kaishijeng opened this issue Feb 25, 2018 · 10 comments

Comments

@kaishijeng
Copy link

@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,

@angelamin
Copy link

angelamin commented Mar 20, 2018

I meet the same problem as yours, and I solved it by clearing the pycache, and I hope it will help you~

@MrLinNing
Copy link

I can get this, the pruned model size is 9.3M which is not 2.2M? @angelamin @kaishijeng is it same as your model?
image

@RichardMrLu
Copy link

emmm, after I run 'python main.py -sr --s 0.0001', my checkpoint.pth.tar is 153M...
Can you help me? Thanks.

@RichardMrLu
Copy link

And it didn't save model_best.pth.tar...

@RichardMrLu
Copy link

I check it, because of pytorch0.4, after test,type(prec1) is Tensor, so change it to type int.
But models are still 153M....

@RichardMrLu
Copy link

@MrLinNing Hello, I only change dataset's path to own Cifar10, how do you save so small model? Thanks for your help.

@RichardMrLu
Copy link

Parameters are 20M, so model size should be (20x1000000x32)/(1024x1024x8)=76.29M
soga

@Coderx7
Copy link

Coderx7 commented Jul 1, 2018

@RichardMrLu : how did you run the script with version 0.4? Can you share your changes?

@RichardMrLu
Copy link

@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)

@helloelliot
Copy link

@RichardMrLu My original model is 160M . Why our models such big with only 20M parameters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants