How to use the larq.constraints.WeightClip function in larq

To help you get started, we’ve selected a few larq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github larq / larq / larq / constraints.py View on Github external
clip_value: The value to clip incoming weights.
    """

    def __init__(self, clip_value=1):
        self.clip_value = clip_value

    def __call__(self, x):
        return tf.clip_by_value(x, -self.clip_value, self.clip_value)

    def get_config(self):
        return {"clip_value": self.clip_value}


# Aliases
@utils.register_keras_custom_object
class weight_clip(WeightClip):
    pass