How to use the larq.layers.QuantDense 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 / zoo / larq_zoo / literature / dorefanet.py View on Github external
def fully_connected_block(self, x, units):
        x = lq.layers.QuantDense(
            units,
            input_quantizer=self.input_quantizer,
            kernel_quantizer=self.kernel_quantizer,
            kernel_constraint=self.kernel_constraint,
            use_bias=False,
        )(x)
        return tf.keras.layers.BatchNormalization(
            scale=False, momentum=0.9, epsilon=1e-4
        )(x)
github larq / larq / larq / models.py View on Github external
import itertools
from dataclasses import dataclass

import numpy as np
import tensorflow.keras.layers as keras_layers
from terminaltables import AsciiTable

import larq.layers as lq_layers

__all__ = ["summary"]

op_count_supported_layer_types = (
    lq_layers.QuantConv2D,
    lq_layers.QuantSeparableConv2D,
    lq_layers.QuantDepthwiseConv2D,
    lq_layers.QuantDense,
    keras_layers.Conv2D,
    keras_layers.SeparableConv2D,
    keras_layers.DepthwiseConv2D,
    keras_layers.Dense,
    keras_layers.Flatten,
    keras_layers.BatchNormalization,
    keras_layers.MaxPool2D,
    keras_layers.AveragePooling2D,
)

mac_containing_layers = (
    lq_layers.QuantConv2D,
    lq_layers.QuantSeparableConv2D,
    lq_layers.QuantDepthwiseConv2D,
    lq_layers.QuantDense,
    keras_layers.Conv2D,