Skip to content

코드 분석

Heeseon Cheon edited this page Oct 11, 2020 · 2 revisions

https://www.notion.so/code-7f2c7ae86b8649ef8812686c8b6e5e61

pruning

  • utils.py
    • get_weight_threshold(model, rate, args)
    • weight_prune(model, threshold, args)
    • get_filter_mask(model, rate, args)
    • filter_prune(model, filter_mask)
    • cal_sparsity(model)

dpf (dynamic pruning with feedback)

  • __init__.py
  • mnn.py
    • Masker(torch.autograd.Function)
      • forward(ctx, x, mask)
      • backward(ctx, grad)
    • MaskConv2d(nn.Conv2d)
      • init(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros')
      • forward(self, input)

models (default ResNet)

  • __init__.py
  • resnet_mask.py
    • BasicBlock(nn.Module)
      • __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None)
      • forward(self, x)
    • Bottleneck(nn.Module)
      • __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None)
      • forward(self, x)
  • ResNet(nn.Module)
    • __init__(self, block, layers, num_classes=1000, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, norm_layer=None)
    • _make_layer(self, block, planes, blocks, stride=1, dilate=False)
    • _forward_impl(self, x)
    • forward(self, x) : _forward_impl(x) 실행
  • ResNet_CIFAR(nn.Module)
    • __init__(self, block, layers, num_classes=10, zero_init_residual=False, groups=1, width_per_group=64, replace_stride_with_dilation=None, norm_layer=None)
    • _make_layer(self, block, planes, blocks, stride=1, dilate=False)
    • _forward_impl(self, x)
    • forward(self, x) : _forward_impl(x) 실행
  • conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1)
  • conv1x1(in_planes, out_planes, stride=1)
  • resnet(data='cifar10', **kwargs) : data 따라 모델 다르게 설정해서 모델 반환
Clone this wiki locally