# tfl.pwl_calibration_layer.LaplacianRegularizer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/pwl_calibration_layer.py#L815-L879) |

Laplacian regularizer for PWL calibration layer.

    tfl.pwl_calibration_layer.LaplacianRegularizer(
        l1=0.0, l2=0.0, is_cyclic=False
    )

Calibrator Laplacian regularization penalizes the change in the calibration
output. It is defined to be:

`l1 * ||delta||_1 + l2 * ||delta||_2^2`

where `delta` is:

`output_keypoints[1:end] - output_keypoints[0:end-1]`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `l1` | l1 regularization amount as float. |
| `l2` | l2 regularization amount as float. |
| `is_cyclic` | Whether the first and last keypoints should take the same output value. |

<br />

## Methods

### `from_config`

    @classmethod
    from_config(
        config
    )

Creates a regularizer from its config.

This method is the reverse of `get_config`,
capable of instantiating the same regularizer from the config
dictionary.

This method is used by TF-Keras `model_to_estimator`, saving and
loading models to HDF5 formats, TF-Keras model cloning, some
visualization utilities, and exporting models to and from JSON.

<br />

<br />

<br />

| Args ||
|---|---|
| `config` | A Python dictionary, typically the output of get_config. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A regularizer instance. ||

<br />

### `get_config`

[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/pwl_calibration_layer.py#L873-L879)

    get_config()

Standard Keras config for serialization.

### `__call__`

[View source](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/pwl_calibration_layer.py#L845-L871)

    __call__(
        x
    )

Returns regularization loss.

<br />

<br />

<br />

| Args ||
|---|---|
| `x` | Tensor of shape: `(k, units)` which represents weights of PWL calibration layer. First row of weights is bias term. All remaining represent delta in y-value compare to previous point (segment heights). |

<br />