Comments (5)
how Pruning the last conv layer affects the first linear layer of the classifier which is (512 7 7, 4096).
It changed the input dimension of the first fc layer.
how can I prune the input weights of classifier according to the last conv layer.
The input weights of classifier does not change with the last conv layer.
from network-slimming.
how Pruning the last conv layer affects the first linear layer of the classifier which is (512 7 7, 4096).
It changed the input dimension of the first fc layer.
how can I prune the input weights of classifier according to the last conv layer.
The input weights of classifier does not change with the last conv layer.
nn.Conv2d(512, 512, 3, padding=1), is changed to nn.Conv2d(450, 412, 3, padding=1)
how this one will change: nn.Linear(in_features=512 * 7 * 7, out_features=4096, bias=True),
class VGGOWN(nn.Module):
def __init__(self):
super(VGGOWN, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 64, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(64, 64, 3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(2, stride=2, ceil_mode=True), # 1/2
# conv2
nn.Conv2d(64, 128, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(128, 128, 3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(2, stride=2, ceil_mode=True), # 1/4
# conv3
nn.Conv2d(128, 256, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(256, 256, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(256, 256, 3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(2, stride=2, ceil_mode=True), # 1/8
# conv4
nn.Conv2d(256, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(512, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(512, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(2, stride=2, ceil_mode=True), # 1/16
# conv5
nn.Conv2d(512, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(512, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.Conv2d(512, 512, 3, padding=1),
nn.ReLU(inplace=True),
nn.MaxPool2d(2, stride=2, ceil_mode=True) # 1/32
)
self.avgpool = nn.AdaptiveAvgPool2d((7, 7))
self.classifier = nn.Sequential(
nn.Linear(in_features=512 * 7 * 7, out_features=4096, bias=True),
nn.ReLU(inplace=True),
nn.Dropout(p=0.5),
nn.Linear(in_features=4096, out_features=4096, bias=True),
nn.ReLU(inplace=True),
nn.Dropout(p=0.5),
nn.Linear(in_features=4096, out_features=1000, bias=True)
)
def forward(self, *input):
x = self.features(input)
#print(x.size)
x = self.avgpool(x)
#print(x.size)
x = x.view(x.size(0), -1)
#print(x.size)
y = self.classifier(x)
return y
thanks
from network-slimming.
Should be nn.Linear(in_features=450 * 7 * 7, out_features=4096, bias=True)
now if i understand the definition of nn.conv2d
correctly.
from network-slimming.
when I load the pretrained state-dict it has already (25088, 4096) weights in linear layer how can I know which one should be prun?
I know which filters I pruned in prev layer I dont know how conv layer weights is mapped to next layer
from network-slimming.
Please try to understand vggprune.py
in detail. Then you will know.
from network-slimming.
Related Issues (20)
- 预测单张照片时,准确率只有0.0几 HOT 2
- Minor Bugs caused by old version
- Sparse Confusion HOT 1
- channel_selection layer intraining process HOT 2
- 剪枝后保存的权重文件和newmodel加载不上 HOT 3
- RuntimeError: Given groups=1, weight of size [15, 14, 1, 1], expected input[64, 16, 32, 32] to have 14 channels, but got 16 channels instead HOT 1
- If the remaining channel for a layer is zero, it reports zero division error HOT 2
- 原论文中的memory是指 HOT 6
- TypeError: item() takes no arguments (1 given) HOT 1
- mnn加载剪枝模型错误 HOT 1
- 经稀疏训练剪枝后模型变小,但是refine微调后模型又变大了
- 关于L1 regular HOT 1
- m.weight.grad.data.add_的问题
- 问题咨询:剪枝后通道数为0 HOT 7
- RuntimeError: CUDA error: device-side assert triggered HOT 1
- About other visions
- 题外话:模型压缩如何入门?对于自己的网络架构该如何着手去写剪枝代码?
- ResNet和DenseNet这种每一层的输入会作为后续多个层的输入,且其BN层是在卷积层之前,在这种情况下,稀疏化是在层的输入末端得到的,一个层选择性接受所有通道的子集去做下一步的卷积运算。
- 对HRNet剪枝,第一个bn的grad是None的问题
- Regarding the calculation of FLOPs after model compression HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from network-slimming.