Skip to content

larq.metrics

scope

scope(metrics=[])
A context manager to set the training metrics to be used in layers.

Example

with larq.metrics.scope(["flip_ratio"]):
    model = tf.keras.models.Sequential(
        [larq.layers.QuantDense(3, kernel_quantizer="ste_sign", input_shape=(32,))]
    )
model.compile(loss="mse", optimizer="sgd")

Arguments

  • metrics: Iterable of metrics to add to layers defined inside this context. Currently only the flip_ratio metric is available.

get_training_metrics

get_training_metrics()
Retrieves a live reference to the training metrics in the current scope.

Updating and clearing training metrics using larq.metrics.scope is preferred, but get_training_metrics can be used to directly access them.

Example

get_training_metrics().clear()
get_training_metrics().add("flip_ratio")

Returns

A set of training metrics in the current scope.