<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-optimization/blob/v0.8.1/tensorflow_model_optimization/python/core/quantization/keras/quantize.py#L233-L285) |

Annotate a `keras` layer to be quantized.

    tfmot.quantization.keras.quantize_annotate_layer(
        to_annotate, quantize_config=None
    )

### Used in the notebooks

| Used in the guide |
|---|
| - [Quantization aware training comprehensive guide](https://www.tensorflow.org/model_optimization/guide/quantization/training_comprehensive_guide) |

This function does not actually quantize the layer. It is merely used to
specify that the layer should be quantized. The layer then gets quantized
accordingly when `quantize_apply` is used.

This method should be used when the user wants to quantize only certain
layers of the model, or change the default behavior of how a layer is
quantized.

#### Annotate a layer:

    model = keras.Sequential([
        layers.Dense(10, activation='relu', input_shape=(100,)),
        quantize_annotate_layer(layers.Dense(2, activation='sigmoid'))
    ])

    # Only the second Dense layer is quantized.
    quantized_model = quantize_apply(model)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `to_annotate` | `keras` layer which needs to be quantized. |
| `quantize_config` | optional `QuantizeConfig` which controls how the layer is quantized. In its absence, the default behavior for the layer is used. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `keras` layer wrapped with `QuantizeAnnotate`. ||

<br />