# tf.keras.regularizers.OrthogonalRegularizer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/regularizers.py#L327-L391) |

Regularizer that encourages input vectors to be orthogonal to each other.

Inherits From: [`Regularizer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/regularizers/Regularizer)

#### View aliases


**Main aliases**

[`tf.keras.regularizers.orthogonal_regularizer`](https://www.tensorflow.org/api_docs/python/tf/keras/regularizers/OrthogonalRegularizer)

<br />

    tf.keras.regularizers.OrthogonalRegularizer(
        factor=0.01, mode='rows'
    )

It can be applied to either the rows of a matrix (`mode="rows"`) or its
columns (`mode="columns"`). When applied to a `Dense` kernel of shape
`(input_dim, units)`, rows mode will seek to make the feature vectors
(i.e. the basis of the output space) orthogonal to each other.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `factor` | Float. The regularization factor. The regularization penalty will be proportional to `factor` times the mean of the dot products between the L2-normalized rows (if `mode="rows"`, or columns if `mode="columns"`) of the inputs, excluding the product of each row/column with itself. Defaults to 0.01. |
| `mode` | String, one of `{"rows", "columns"}`. Defaults to `"rows"`. In rows mode, the regularization effect seeks to make the rows of the input orthogonal to each other. In columns mode, it seeks to make the columns of the input orthogonal to each other. |

<br />

#### Example:

    regularizer = tf.keras.regularizers.OrthogonalRegularizer(factor=0.01)
    layer = tf.keras.layers.Dense(units=4, kernel_regularizer=regularizer)

## Methods

### `from_config`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/regularizers.py#L171-L189)

    @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 Keras `model_to_estimator`, saving and
loading models to HDF5 formats, 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/keras-team/keras/tree/v2.13.1/keras/regularizers.py#L390-L391)

    get_config()

Returns the config of the regularizer.

An regularizer config is a Python dictionary (serializable)
containing all configuration parameters of the regularizer.
The same regularizer can be reinstantiated later
(without any saved state) from this configuration.

This method is optional if you are just training and executing models,
exporting to and from SavedModels, or using weight checkpoints.

This method is required for Keras `model_to_estimator`, saving and
loading models to HDF5 formats, Keras model cloning, some visualization
utilities, and exporting models to and from JSON.

<br />

<br />

<br />

| Returns ||
|---|---|
| Python dictionary. ||

<br />

### `__call__`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/regularizers.py#L367-L388)

    __call__(
        inputs
    )

Compute a regularization penalty from an input tensor.