varungohil / Generalizing-Lottery-Tickets

This repository contains code to replicate the experiments given in NeurIPS 2019 paper "One ticket to win them all: generalizing lottery ticket initializations across datasets and optimizers"
https://rescience.github.io/bibliography/Gohil_2020.html
MIT License
51 stars 9 forks source link

Error when running iterative_pruning.py #2

Closed authwork closed 4 years ago

authwork commented 4 years ago
> python3 train.py --architecture=resnet50 --dataset=cifar10 --model-saving-path=./resnet50_cifar10/
> python3 iterative_pruning.py --architecture=resnet50 --source-dataset=cifar10 --target-dataset=cifar100 --init-path=resnet50_cifar10/2 --model-saving-path=resnet50_prune

Note. --init_path : Path to model with winning ticket initialization It seems that init-path is necessary to run iterative_pruning.py (in README.md)

image

varungohil commented 4 years ago

Hi authwork,

I think the error is due to incorrect layer_index for masks array. I have pushed an update that indexes the masks array correctly.

Unfortunately, I am away from office and will not be able to verify the solution till January 2020. Could you please run the code with the latest commit and check?

Thanks, Varun

cmleecm commented 4 years ago

After successfully running train.py, this is the error when I run iterative_pruning.py. Please help.

python iterative_pruning.py --architecture=resnet50 --source-dataset=cifar10 --target-dataset=cifar100 --model-saving-path=../model_save/prune --init-path=../model_save/train/90 Using cuda:0 device. Files already downloaded and verified Iterative Pruning started Running pruning iteration 0 Running pruning iteration 1 Fraction of weights pruned = 4737256/23686272 = 0.20000006754967603 Traceback (most recent call last): File "iterative_pruning.py", line 238, in prune_iteratively(model, dataloader, args.architecture, args.optimizer, device, args.model_saving_path, args.init_path, args.random, False) File "iterative_pruning.py", line 182, in pruneiteratively params.data.mul(masks[layer_index].to(device)) RuntimeError: output with shape [64, 64, 1, 1] doesn't match the broadcast shape [64, 64, 1, 64]

cmleecm commented 4 years ago

The problem goes away with the latest iterative_pruning.py update.

varungohil commented 4 years ago

Thank you @cmleecm for verifying. Closing this issue.