Zj-BinXia / SSL

This project is the official implementation of 'Structured Sparsity Learning for Efficient Video Super-Resolution', CVPR2023
95 stars 6 forks source link

When I use it on other models, I get the missing key error #10

Open sunyclj opened 11 months ago

sunyclj commented 11 months ago

Missing key(s) in state_dict: "forward_resblocks.main.2.0.conv1.act_scale_pre", "forward_resblocks.main.2.0.conv1.act_scale", "forward_resblocks.main.2.0.conv2.act_scale", .................... please,what's the reason? Conv2D_WN_Pre contains 'self.act_scale_pre = nn.Parameter(torch.ones(in_channels).view(1, -1, 1, 1), requires_grad=True) self.act_scale = nn.Parameter(torch.ones(out_channels).view(1, -1, 1, 1), requires_grad=True)', does it need to be defined when training a model without pruning?

Zj-BinXia commented 11 months ago

需要定义,这是给后面剪枝用的,我当时做实验尝试了两点,根据act_scale的大小进行剪枝或者根据权重的L1-Norm进行剪枝,所以保留了这个设定。其实剪枝最早是在high level任务上进行的,那里的网络会使用batchNorm,这是一个天然的gate,因此有人常使用BN里面的系数大小定义一个通道的重要性进行剪枝。但是low-level任务中一般不用这个BN,所以又加了一个全部定义为1的系数来简单的衡量一下通道的重要性。

sunyclj commented 11 months ago

需要定义,这是给后面剪枝用的,我当时做实验尝试了两点,根据act_scale的大小进行剪枝或者根据权重的L1-Norm进行剪枝,所以保留了这个设定。其实剪枝最早是在high level任务上进行的,那里的网络会使用batchNorm,这是一个天然的gate,因此有人常使用BN里面的系数大小定义一个通道的重要性进行剪枝。但是low-level任务中一般不用这个BN,所以又加了一个全部定义为1的系数来简单的衡量一下通道的重要性。

明白了,谢谢! 请问在./basicsr/pruner/utils.py中定义了函数adjust_pr,这是什么作用呢?在这之前,已经确定了pruned_wg和kept_wg,为什么还要调整呢?