Exemplo n.º 1
0
    def weight_op(self):
        padding = get_same_padding(self.kernel_size)
        if isinstance(padding, int):
            padding *= self.dilation
        else:
            padding[0] *= self.dilation
            padding[1] *= self.dilation

        weight_dict = OrderedDict()
        weight_dict['depth_conv'] = nn.Conv2d(self.in_channels,
                                              self.in_channels,
                                              kernel_size=self.kernel_size,
                                              stride=self.stride,
                                              padding=padding,
                                              dilation=self.dilation,
                                              groups=self.in_channels,
                                              bias=False)
        weight_dict['point_conv'] = nn.Conv2d(self.in_channels,
                                              self.out_channels,
                                              kernel_size=1,
                                              groups=self.groups,
                                              bias=self.bias)
        if self.has_shuffle and self.groups > 1:
            weight_dict['shuffle'] = ShuffleLayer(self.groups)
        return weight_dict
Exemplo n.º 2
0
    def weight_op(self):
        padding = get_same_padding(self.kernel_size)
        if isinstance(padding, int):
            padding *= self.dilation
        else:
            padding[0] *= self.dilation
            padding[1] *= self.dilation

        weight_dict = OrderedDict()
        # weight_dict['conv'] = nn.Conv2d(
        #     self.in_channels, self.out_channels, kernel_size=self.kernel_size, stride=self.stride, padding=padding,
        #     dilation=self.dilation, groups=self.groups, bias=self.bias
        # )
        weight_dict['conv'] = LsqConv(self.in_channels,
                                      self.out_channels,
                                      kernel_size=self.kernel_size,
                                      quan_name_w='lsq',
                                      quan_name_a='lsq',
                                      nbit_w=self.nbit_w,
                                      nbit_a=self.nbit_a,
                                      stride=self.stride,
                                      padding=padding,
                                      dilation=self.dilation,
                                      groups=self.groups,
                                      bias=self.bias)
        if self.has_shuffle and self.groups > 1:
            weight_dict['shuffle'] = ShuffleLayer(self.groups)

        return weight_dict