Exemple #1
0
 def __init__(self):
     super().__init__()
     self.act = QuantIdentity(bit_width=7,
                              act_quant=ShiftedUint8ActPerTensorFloat,
                              return_quant_tensor=True)
     self.pool = QuantMaxPool2d(kernel_size=KERNEL_SIZE,
                                stride=KERNEL_SIZE,
                                return_quant_tensor=False)
 def __init__(self):
     super().__init__()
     self.conv1 = QuantConv2d(
         out_channels=OUT_CH,
         in_channels=IN_CH,
         kernel_size=KERNEL_SIZE,
         bias=False,
         weight_quant=Int8WeightPerTensorFixedPoint,
         input_quant=Int8ActPerTensorFixedPoint,
         output_quant=Int8ActPerTensorFixedPoint,
         return_quant_tensor=True)
     self.max_pool = QuantMaxPool2d(kernel_size=2, stride=2, return_quant_tensor=False)
     self.conv1.weight.data.uniform_(-0.01, 0.01)
Exemple #3
0
 def __init__(self):
     super().__init__()
     self.conv1 = QuantConv2d(kernel_size=KERNEL_SIZE,
                              in_channels=CHANNELS,
                              out_channels=CHANNELS,
                              weight_quant=DPUv1WeightQuantInjector,
                              bias_quant=None,
                              output_quant=DPUv1OutputQuantInjector,
                              bias=False,
                              return_quant_tensor=True)
     self.act1 = QuantReLU(act_quant=DPUv1ActQuantInjector,
                           return_quant_tensor=True)
     self.conv2 = QuantConv2d(kernel_size=KERNEL_SIZE,
                              in_channels=CHANNELS,
                              out_channels=CHANNELS,
                              weight_quant=DPUv1WeightQuantInjector,
                              bias_quant=None,
                              output_quant=DPUv1OutputQuantInjector,
                              bias=False,
                              return_quant_tensor=True)
     self.act2 = QuantReLU(act_quant=DPUv1ActQuantInjector,
                           return_quant_tensor=True)
     self.conv3 = QuantConv2d(kernel_size=KERNEL_SIZE,
                              in_channels=CHANNELS,
                              out_channels=CHANNELS,
                              weight_quant=DPUv1WeightQuantInjector,
                              bias_quant=None,
                              output_quant=DPUv1OutputQuantInjector,
                              bias=False,
                              return_quant_tensor=True)
     self.act3 = QuantReLU(act_quant=DPUv1ActQuantInjector,
                           return_quant_tensor=False)
     self.max_pool = QuantMaxPool2d(kernel_size=KERNEL_SIZE,
                                    stride=1,
                                    return_quant_tensor=True)
     self.eltwise_add = QuantEltwiseAdd(
         input_quant=DPUv1OutputQuantInjector,
         output_quant=DPUv1ActQuantInjector,
         return_quant_tensor=True)
     self.linear = nn.Linear(FC_IN_SIZE, CHANNELS)
Exemple #4
0
 def __init__(self):
     super().__init__()
     self.act = QuantIdentity(return_quant_tensor=True)
     self.pool = QuantMaxPool2d(kernel_size=2,
                                return_quant_tensor=False)