qkeras.qmac

Classes

QScaleShift(*args, **kwargs)

Quantized scale and shift layer.

class qkeras.qmac.QScaleShift(*args, **kwargs)[source]

Bases: Layer

Quantized scale and shift layer.

output = scale * x + bias where scale and bias are each of shape (1,).

QScaleShift is similar to the special case in QDepthwiseConv2D

where kernel_size=(1,1). However there are several differences:

  1. There is no concept of padding and striding in QScaleShift since

it’s not a conv layer;

  1. QDepthwiseConv2D expected min_ndim=4 for input shape; while QScaleShift

input could be any shape;

  1. In QDepthwiseConv2D each output channel has its own weight value;

while QScaleShift share the same weight across the entire input tensor.

  1. Since it’s not a Conv operation, hardware implementation for

QScaleShift and QDWConv2D is fundamentally different. Therefore it makes sense to separate them as two different types of layers.

build(input_shape)[source]
call(inputs)[source]
get_config()[source]

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

get_prunable_weights()[source]
get_quantization_config()[source]
get_quantizers()[source]