I am using a modified predict.py for testing a pruned SqueezeNet Model
[phung@archlinux SqueezeNet-Pruning]$ python predict.py --image 3_100.jpg --model model_prunned --num_class 2
/usr/lib/python3.7/site-packages/torchvision/models/squeezenet.py:94: UserWarning: nn.init.kaiming_uniform is now deprecated in favor of nn.init.kaiming_uniform_.
init.kaiming_uniform(m.weight.data)
/usr/lib/python3.7/site-packages/torchvision/models/squeezenet.py:92: UserWarning: nn.init.normal is now deprecated in favor of nn.init.normal_.
init.normal(m.weight.data, mean=0.0, std=0.01)
Traceback (most recent call last):
File "predict.py", line 30, in <module>
model.load_state_dict(checkpoint)
File "/usr/lib/python3.7/site-packages/torch/nn/modules/module.py", line 723, in load_state_dict
self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ModifiedSqueezeNetModel:
size mismatch for features.0.weight: copying a param of torch.Size([28, 3, 3, 3]) from checkpoint, where the shape is torch.Size([64, 3, 3, 3]) in current model.
size mismatch for features.0.bias: copying a param of torch.Size([28]) from checkpoint, where the shape is torch.Size([64]) in current model.
size mismatch for features.3.squeeze.weight: copying a param of torch.Size([16, 28, 1, 1]) from checkpoint, where the shape is torch.Size([16, 64, 1, 1]) in current model.
size mismatch for features.3.expand1x1.weight: copying a param of torch.Size([43, 16, 1, 1]) from checkpoint, where the shape is torch.Size([64, 16, 1, 1]) in current model.
size mismatch for features.3.expand1x1.bias: copying a param of torch.Size([43]) from checkpoint, where the shape is torch.Size([64]) in current model.
size mismatch for features.3.expand3x3.weight: copying a param of torch.Size([41, 16, 3, 3]) from checkpoint, where the shape is torch.Size([64, 16, 3, 3]) in current model.
size mismatch for features.3.expand3x3.bias: copying a param of torch.Size([41]) from checkpoint, where the shape is torch.Size([64]) in current model.
size mismatch for features.4.squeeze.weight: copying a param of torch.Size([16, 84, 1, 1]) from checkpoint, where the shape is torch.Size([16, 128, 1, 1]) in current model.
size mismatch for features.4.expand1x1.weight: copying a param of torch.Size([38, 16, 1, 1]) from checkpoint, where the shape is torch.Size([64, 16, 1, 1]) in current model.
size mismatch for features.4.expand1x1.bias: copying a param of torch.Size([38]) from checkpoint, where the shape is torch.Size([64]) in current model.
size mismatch for features.4.expand3x3.weight: copying a param of torch.Size([29, 16, 3, 3]) from checkpoint, where the shape is torch.Size([64, 16, 3, 3]) in current model.
size mismatch for features.4.expand3x3.bias: copying a param of torch.Size([29]) from checkpoint, where the shape is torch.Size([64]) in current model.
size mismatch for features.6.squeeze.weight: copying a param of torch.Size([32, 67, 1, 1]) from checkpoint, where the shape is torch.Size([32, 128, 1, 1]) in current model.
size mismatch for features.6.expand1x1.weight: copying a param of torch.Size([79, 32, 1, 1]) from checkpoint, where the shape is torch.Size([128, 32, 1, 1]) in current model.
size mismatch for features.6.expand1x1.bias: copying a param of torch.Size([79]) from checkpoint, where the shape is torch.Size([128]) in current model.
size mismatch for features.6.expand3x3.weight: copying a param of torch.Size([65, 32, 3, 3]) from checkpoint, where the shape is torch.Size([128, 32, 3, 3]) in current model.
size mismatch for features.6.expand3x3.bias: copying a param of torch.Size([65]) from checkpoint, where the shape is torch.Size([128]) in current model.
size mismatch for features.7.squeeze.weight: copying a param of torch.Size([32, 144, 1, 1]) from checkpoint, where the shape is torch.Size([32, 256, 1, 1]) in current model.
size mismatch for features.7.expand1x1.weight: copying a param of torch.Size([80, 32, 1, 1]) from checkpoint, where the shape is torch.Size([128, 32, 1, 1]) in current model.
size mismatch for features.7.expand1x1.bias: copying a param of torch.Size([80]) from checkpoint, where the shape is torch.Size([128]) in current model.
size mismatch for features.7.expand3x3.weight: copying a param of torch.Size([53, 32, 3, 3]) from checkpoint, where the shape is torch.Size([128, 32, 3, 3]) in current model.
size mismatch for features.7.expand3x3.bias: copying a param of torch.Size([53]) from checkpoint, where the shape is torch.Size([128]) in current model.
size mismatch for features.9.squeeze.weight: copying a param of torch.Size([48, 133, 1, 1]) from checkpoint, where the shape is torch.Size([48, 256, 1, 1]) in current model.
size mismatch for features.9.expand1x1.weight: copying a param of torch.Size([84, 48, 1, 1]) from checkpoint, where the shape is torch.Size([192, 48, 1, 1]) in current model.
size mismatch for features.9.expand1x1.bias: copying a param of torch.Size([84]) from checkpoint, where the shape is torch.Size([192]) in current model.
size mismatch for features.9.expand3x3.weight: copying a param of torch.Size([83, 48, 3, 3]) from checkpoint, where the shape is torch.Size([192, 48, 3, 3]) in current model.
size mismatch for features.9.expand3x3.bias: copying a param of torch.Size([83]) from checkpoint, where the shape is torch.Size([192]) in current model.
size mismatch for features.10.squeeze.weight: copying a param of torch.Size([48, 167, 1, 1]) from checkpoint, where the shape is torch.Size([48, 384, 1, 1]) in current model.
size mismatch for features.10.expand1x1.weight: copying a param of torch.Size([82, 48, 1, 1]) from checkpoint, where the shape is torch.Size([192, 48, 1, 1]) in current model.
size mismatch for features.10.expand1x1.bias: copying a param of torch.Size([82]) from checkpoint, where the shape is torch.Size([192]) in current model.
size mismatch for features.10.expand3x3.weight: copying a param of torch.Size([81, 48, 3, 3]) from checkpoint, where the shape is torch.Size([192, 48, 3, 3]) in current model.
size mismatch for features.10.expand3x3.bias: copying a param of torch.Size([81]) from checkpoint, where the shape is torch.Size([192]) in current model.
size mismatch for features.11.squeeze.weight: copying a param of torch.Size([64, 163, 1, 1]) from checkpoint, where the shape is torch.Size([64, 384, 1, 1]) in current model.
size mismatch for features.11.expand1x1.weight: copying a param of torch.Size([76, 64, 1, 1]) from checkpoint, where the shape is torch.Size([256, 64, 1, 1]) in current model.
size mismatch for features.11.expand1x1.bias: copying a param of torch.Size([76]) from checkpoint, where the shape is torch.Size([256]) in current model.
size mismatch for features.11.expand3x3.weight: copying a param of torch.Size([68, 64, 3, 3]) from checkpoint, where the shape is torch.Size([256, 64, 3, 3]) in current model.
size mismatch for features.11.expand3x3.bias: copying a param of torch.Size([68]) from checkpoint, where the shape is torch.Size([256]) in current model.
size mismatch for features.12.squeeze.weight: copying a param of torch.Size([64, 144, 1, 1]) from checkpoint, where the shape is torch.Size([64, 512, 1, 1]) in current model.
size mismatch for features.12.expand1x1.weight: copying a param of torch.Size([16, 64, 1, 1]) from checkpoint, where the shape is torch.Size([256, 64, 1, 1]) in current model.
size mismatch for features.12.expand1x1.bias: copying a param of torch.Size([16]) from checkpoint, where the shape is torch.Size([256]) in current model.
size mismatch for features.12.expand3x3.weight: copying a param of torch.Size([14, 64, 3, 3]) from checkpoint, where the shape is torch.Size([256, 64, 3, 3]) in current model.
size mismatch for features.12.expand3x3.bias: copying a param of torch.Size([14]) from checkpoint, where the shape is torch.Size([256]) in current model.
size mismatch for classifier.1.weight: copying a param of torch.Size([2, 30, 1, 1]) from checkpoint, where the shape is torch.Size([2, 512, 1, 1]) in current model.
[phung@archlinux SqueezeNet-Pruning]$
Pruned squeezenet model
ModifiedSqueezeNetModel(
(classifier): Sequential(
(0): Dropout(p=0.5)
(1): Conv2d(30, 2, kernel_size=(1, 1), stride=(1, 1))
(2): ReLU(inplace)
(3): AvgPool2d(kernel_size=13, stride=1, padding=0)
)
(features): Sequential(
(0): Conv2d(3, 28, kernel_size=(3, 3), stride=(2, 2))
(1): ReLU(inplace)
(2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)
(3): Fire(
(squeeze): Conv2d(28, 16, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(16, 43, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(16, 41, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(4): Fire(
(squeeze): Conv2d(84, 16, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(16, 38, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(16, 29, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)
(6): Fire(
(squeeze): Conv2d(67, 32, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(32, 79, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(32, 65, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(7): Fire(
(squeeze): Conv2d(144, 32, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(32, 80, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(32, 53, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(8): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)
(9): Fire(
(squeeze): Conv2d(133, 48, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(48, 84, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(48, 83, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(10): Fire(
(squeeze): Conv2d(167, 48, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(48, 82, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(48, 81, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(11): Fire(
(squeeze): Conv2d(163, 64, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(64, 76, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(64, 68, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
(12): Fire(
(squeeze): Conv2d(144, 64, kernel_size=(1, 1), stride=(1, 1))
(squeeze_activation): ReLU(inplace)
(expand1x1): Conv2d(64, 16, kernel_size=(1, 1), stride=(1, 1))
(expand1x1_activation): ReLU(inplace)
(expand3x3): Conv2d(64, 14, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(expand3x3_activation): ReLU(inplace)
)
)
)