pytorch-pruning icon indicating copy to clipboard operation
pytorch-pruning copied to clipboard

low accuracy value after pruning and retraining

Open buttercutter opened this issue 6 years ago • 0 comments

When I use my own modified pytorch-pruning for python 3 with this fruits dataset , I have quite low accuracy value. May I know why ?

Besides, how do we use the output model_prunned ? Do we have to write our own pytorch code to test any random input images not in the test and training set ?

[phung@archlinux pytorch-pruning]$ ls -al test/ total 16 drwxr-xr-x 2 phung phung 4096 Oct 20 20:55 . drwxr-xr-x 6 phung phung 4096 Oct 20 23:57 .. lrwxrwxrwx 1 phung phung 96 Oct 20 20:54 Lemon -> /home/phung/Documents/Grive/Personal/Coursera/Machine_Learning/dataset/kaggle_fruits/Test/Lemon/ lrwxrwxrwx 1 phung phung 97 Oct 20 20:55 Orange -> /home/phung/Documents/Grive/Personal/Coursera/Machine_Learning/dataset/kaggle_fruits/Test/Orange/ [phung@archlinux pytorch-pruning]$ ls -al train/ total 16 drwxr-xr-x 2 phung phung 4096 Oct 20 20:54 . drwxr-xr-x 6 phung phung 4096 Oct 20 23:57 .. lrwxrwxrwx 1 phung phung 100 Oct 20 20:54 Lemon -> /home/phung/Documents/Grive/Personal/Coursera/Machine_Learning/dataset/kaggle_fruits/Training/Lemon/ lrwxrwxrwx 1 phung phung 100 Oct 20 20:53 Orange -> /home/phung/Documents/Grive/Personal/Coursera/Machine_Learning/dataset/kaggle_fruits/Training/Lemon/ [phung@archlinux pytorch-pruning]$ python finetune.py --train && python finetune.py --prune /usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:187: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. warnings.warn("The use of the transforms.Scale transform is deprecated, " + /usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:562: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead. warnings.warn("The use of the transforms.RandomSizedCrop transform is deprecated, " + Epoch: 0 Accuracy: 0.49382716049382713 Epoch: 1 Accuracy: 0.49382716049382713 Epoch: 2 Accuracy: 0.4876543209876543 Epoch: 3 Accuracy: 0.5339506172839507 Epoch: 4 Accuracy: 0.49382716049382713 Epoch: 5 Accuracy: 0.49382716049382713 Epoch: 6 Accuracy: 0.49382716049382713 Epoch: 7 Accuracy: 0.3765432098765432 Epoch: 8 Accuracy: 0.49382716049382713 Epoch: 9 Accuracy: 0.5 Epoch: 10 Accuracy: 0.49382716049382713 Epoch: 11 Accuracy: 0.49382716049382713 Epoch: 12 Accuracy: 0.49382716049382713 Epoch: 13 Accuracy: 0.24691358024691357 Epoch: 14 Accuracy: 0.3333333333333333 Epoch: 15 Accuracy: 0.4845679012345679 Epoch: 16 Accuracy: 0.5 Epoch: 17 Accuracy: 0.49382716049382713 Epoch: 18 Accuracy: 0.5030864197530864 Epoch: 19 Accuracy: 0.49382716049382713 Finished fine tuning. /usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:187: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. warnings.warn("The use of the transforms.Scale transform is deprecated, " + /usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:562: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead. warnings.warn("The use of the transforms.RandomSizedCrop transform is deprecated, " + Accuracy: 0.49382716049382713 Number of prunning iterations to reduce 67% filters 5 Ranking filters.. Layers that will be prunned {17: 62, 28: 117, 10: 19, 24: 57, 12: 20, 7: 8, 19: 57, 0: 9, 26: 60, 21: 72, 14: 22, 5: 6, 2: 3} Prunning filters.. Filters prunned 87.87878787878788% Accuracy: 0.49382716049382713 Fine tuning to recover from prunning iteration. Epoch: 0 Accuracy: 0.5061728395061729 Epoch: 1 Accuracy: 0.4722222222222222 Epoch: 2 Accuracy: 0.5061728395061729 Epoch: 3 Accuracy: 0.49382716049382713 Epoch: 4 Accuracy: 0.558641975308642 Epoch: 5 Accuracy: 0.7469135802469136 Epoch: 6 Accuracy: 0.7314814814814815 Epoch: 7 Accuracy: 0.6234567901234568 Epoch: 8 Accuracy: 0.5061728395061729 Epoch: 9 Accuracy: 0.5401234567901234 Finished fine tuning. Ranking filters.. Layers that will be prunned {28: 97, 21: 88, 19: 53, 17: 42, 24: 63, 26: 103, 12: 16, 5: 5, 10: 18, 14: 18, 7: 6, 2: 2, 0: 1} Prunning filters.. Filters prunned 75.75757575757575% Accuracy: 0.49382716049382713 Fine tuning to recover from prunning iteration. Epoch: 0 Accuracy: 0.5061728395061729 Epoch: 1 Accuracy: 0.404320987654321 Epoch: 2 Accuracy: 0.24691358024691357 Epoch: 3 Accuracy: 0.5030864197530864 Epoch: 4 Accuracy: 0.4012345679012346 Epoch: 5 Accuracy: 0.5061728395061729 Epoch: 6 Accuracy: 0.5061728395061729 Epoch: 7 Accuracy: 0.5061728395061729 Epoch: 8 Accuracy: 0.5061728395061729 Epoch: 9 Accuracy: 0.5061728395061729 Finished fine tuning. Ranking filters.. Layers that will be prunned {28: 90, 26: 64, 12: 22, 24: 87, 17: 62, 21: 52, 7: 8, 5: 8, 19: 63, 10: 24, 0: 4, 14: 26, 2: 2} Prunning filters.. Filters prunned 63.63636363636363% Accuracy: 0.5061728395061729 Fine tuning to recover from prunning iteration. Epoch: 0 Accuracy: 0.5061728395061729 Epoch: 1 Accuracy: 0.49382716049382713 Epoch: 2 Accuracy: 0.49382716049382713 Epoch: 3 Accuracy: 0.6604938271604939 Epoch: 4 Accuracy: 1.0 Epoch: 5 Accuracy: 0.6790123456790124 Epoch: 6 Accuracy: 0.5061728395061729 Epoch: 7 Accuracy: 0.5061728395061729 Epoch: 8 Accuracy: 0.5679012345679012 Epoch: 9 Accuracy: 0.9845679012345679 Finished fine tuning. Ranking filters.. Layers that will be prunned {28: 75, 14: 25, 26: 74, 21: 88, 19: 61, 7: 14, 17: 49, 24: 66, 10: 25, 0: 6, 12: 18, 5: 7, 2: 4} Prunning filters.. Filters prunned 51.515151515151516% Accuracy: 0.6358024691358025 Fine tuning to recover from prunning iteration. Epoch: 0 Accuracy: 0.7623456790123457 Epoch: 1 Accuracy: 0.7623456790123457 Epoch: 2 Accuracy: 0.6851851851851852 Epoch: 3 Accuracy: 0.8950617283950617 Epoch: 4 Accuracy: 0.9660493827160493 Epoch: 5 Accuracy: 1.0 Epoch: 6 Accuracy: 0.49382716049382713 Epoch: 7 Accuracy: 0.49691358024691357 Epoch: 8 Accuracy: 0.9691358024691358 Epoch: 9 Accuracy: 0.9783950617283951 Finished fine tuning. Ranking filters.. Layers that will be prunned {28: 73, 26: 70, 24: 82, 19: 78, 14: 35, 17: 56, 21: 49, 0: 3, 5: 11, 12: 27, 10: 19, 7: 6, 2: 3} Prunning filters.. Filters prunned 39.39393939393939% Accuracy: 0.9074074074074074 Fine tuning to recover from prunning iteration. Epoch: 0 Accuracy: 0.8364197530864198 Epoch: 1 Accuracy: 0.9691358024691358 Epoch: 2 Accuracy: 0.49382716049382713 Epoch: 3 Accuracy: 0.5092592592592593 Epoch: 4 Accuracy: 0.5864197530864198 Epoch: 5 Accuracy: 0.49382716049382713 Epoch: 6 Accuracy: 0.49382716049382713 Epoch: 7 Accuracy: 1.0 Epoch: 8 Accuracy: 1.0 Epoch: 9 Accuracy: 0.8703703703703703 Finished fine tuning. Finished. Going to fine tune the model a bit more Epoch: 0 Accuracy: 0.49382716049382713 Epoch: 1 Accuracy: 0.8333333333333334 Epoch: 2 Accuracy: 0.7561728395061729 Epoch: 3 Accuracy: 0.49382716049382713 Epoch: 4 Accuracy: 0.5370370370370371 Epoch: 5 Accuracy: 1.0 Epoch: 6 Accuracy: 1.0 Epoch: 7 Accuracy: 0.9135802469135802 Epoch: 8 Accuracy: 0.6666666666666666 Epoch: 9 Accuracy: 1.0 Epoch: 10 Accuracy: 0.49382716049382713 Epoch: 11 Accuracy: 1.0 Epoch: 12 Accuracy: 0.49382716049382713 Epoch: 13 Accuracy: 0.49382716049382713 Epoch: 14 Accuracy: 0.49382716049382713 Finished fine tuning. [phung@archlinux pytorch-pruning]$ ls -al total 645652 drwxr-xr-x 6 phung phung 4096 Oct 20 23:57 . drwxr-xr-x 6 phung phung 4096 Oct 5 08:04 .. -rw-r--r-- 1 phung phung 1695 Oct 15 23:50 dataset.py -rw-r--r-- 1 phung phung 9323 Oct 16 09:16 finetune.py drwxr-xr-x 8 phung phung 4096 Oct 20 21:53 .git -rw-r--r-- 1 phung phung 50 Oct 20 20:58 .gitignore -rw-r--r-- 1 phung phung 537103112 Oct 20 21:49 model -rw-r--r-- 1 phung phung 123976929 Oct 20 23:57 model_prunned -rw-r--r-- 1 phung phung 4939 Oct 20 21:15 prune.py drwxr-xr-x 2 phung phung 4096 Oct 20 21:18 pycache -rw-r--r-- 1 phung phung 1488 Sep 27 22:54 README.md drwxr-xr-x 2 phung phung 4096 Oct 20 20:55 test drwxr-xr-x 2 phung phung 4096 Oct 20 20:54 train [phung@archlinux pytorch-pruning]$

buttercutter avatar Oct 20 '18 12:10 buttercutter