INCHEON-CHO / Dynamic_Model_Pruning_with_Feedback

Implement of Dynamic Model Pruning with Feedback with pytorch
39 stars 5 forks source link

TypeError: Conv2d._conv_forward() missing 1 required positional argument: 'bias' #3

Open 3droot opened 2 years ago

3droot commented 2 years ago

Hi Running this script cause the error in line 26 mnn.py "python main.py cifar10 --datapath DATAPATH -a resnet --layers 56 -C -g 0 --save prune.pth -P --prune-type unstructured --prune-freq 16 --prune-rate 0.9 --prune-imp L2 --epochs 10 --batch-size 80 --lr 0.2 --wd 1e-4 --nesterov --scheduler multistep --milestones 150 225 --gamma 0.1"

" Conv2d._conv_forward() missing 1 required positional argument: 'bias'"

mjalali commented 1 year ago

Hi, I had the same error and I did this:

  1. downgrade the torch and torchvision version:

    pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

  2. Delete the ImageNet import from data.py (line 3).

  3. Comment the body of the imagenet_loader function.

Good luck!

southamptonzeng commented 8 months ago

I have encountered the same issue. Have you resolved this problem?

$ python main.py cifar10 --datapath DATAPATH -a resnet --layers 56 -C -g 0 --save prune.pth -P --prune-type unstructured --prune-freq 16 --prune-rate 0.9 --prune-imp L2 --epochs 300 --batch-size 128 --lr 0.2 --wd 1e-4 --nesterov --scheduler multistep --milestones 150 225 --gamma 0.1

=> creating model 'resnet56' ==> Load data.. Files already downloaded and verified Files already downloaded and verified ===> Data loading time: 0m 1.67s ===> Data loaded..

==> resnet56/cifar10 training ==> Epoch: 0, lr = 0.2 ===> [ Training ] Traceback (most recent call last): File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 336, in main(args) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 130, in main acc1_train, acc5_train = train(args, train_loader, File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 254, in train output = model(input) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/models/resnet_mask.py", line 292, in forward return self._forward_impl(x) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/models/resnet_mask.py", line 278, in _forward_impl x = self.conv1(x) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/dpf/mnn.py", line 26, in forward return super(MaskConv2d, self)._conv_forward(input, masked_weight) TypeError: _conv_forward() missing 1 required positional argument: 'bias'

southamptonzeng commented 8 months ago

I have encountered the same issue. Have you resolved this problem?

$ python main.py cifar10 --datapath DATAPATH -a resnet --layers 56 -C -g 0 --save prune.pth -P --prune-type unstructured --prune-freq 16 --prune-rate 0.9 --prune-imp L2 --epochs 300 --batch-size 128 --lr 0.2 --wd 1e-4 --nesterov --scheduler multistep --milestones 150 225 --gamma 0.1 => creating model 'resnet56' ==> Load data.. Files already downloaded and verified Files already downloaded and verified ===> Data loading time: 0m 1.67s ===> Data loaded.. ==> resnet56/cifar10 training ==> Epoch: 0, lr = 0.2 ===> [ Training ] Traceback (most recent call last): File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 336, in main(args) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 130, in main acc1_train, acc5_train = train(args, train_loader, File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/main.py", line 254, in train output = model(input) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/models/resnet_mask.py", line 292, in forward return self._forward_impl(x) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/models/resnet_mask.py", line 278, in _forward_impl x = self.conv1(x) File "/home/worker1/anaconda3/envs/ModelPrune/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/worker1/zengzh688/Dynamic_Model_Pruning_with_Feedback/pruning/dpf/mnn.py", line 26, in forward return super(MaskConv2d, self)._conv_forward(input, masked_weight) TypeError: _conv_forward() missing 1 required positional argument: 'bias'

Sorry, I have not found any codes that are related to feedback pruning. Hope maybe I am wrong.