コード例 #1
0
ファイル: layers_base.py プロジェクト: zivzone/larq
    def __init__(
        self,
        *args,
        depthwise_quantizer: Optional[Quantizer] = None,
        pointwise_quantizer: Optional[Quantizer] = None,
        **kwargs,
    ):
        self.depthwise_quantizer = quantizers.get_kernel_quantizer(
            depthwise_quantizer)
        self.pointwise_quantizer = quantizers.get_kernel_quantizer(
            pointwise_quantizer)

        super().__init__(*args, **kwargs)
        if _is_binary(
                self.depthwise_quantizer) and not self.depthwise_constraint:
            log.warning(
                "Using a binary `depthwise_quantizer` without setting `depthwise_constraint` "
                "may result in starved weights (where the gradient is always zero)."
            )
        if _is_binary(
                self.pointwise_quantizer) and not self.pointwise_constraint:
            log.warning(
                "Using a binary `pointwise_quantizer` without setting `pointwise_constraint` "
                "may result in starved weights (where the gradient is always zero)."
            )
コード例 #2
0
ファイル: layers_base.py プロジェクト: lkindrat-xmos/larq
    def __init__(self, *args, kernel_quantizer=None, **kwargs):
        self.kernel_quantizer = quantizers.get_kernel_quantizer(kernel_quantizer)

        super().__init__(*args, **kwargs)
        if kernel_quantizer and not self.kernel_constraint:
            log.warning(
                "Using a weight quantizer without setting `kernel_constraint` "
                "may result in starved weights (where the gradient is always zero)."
            )