# tf.compat.v1.layers.Layer

<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/legacy_tf_layers/base.py#L156-L653) |

Base layer class.

Inherits From: [`Layer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/layers/Layer), [`Module`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Module)

    tf.compat.v1.layers.Layer(
        trainable=True, name=None, dtype=None, **kwargs
    )

It is considered legacy, and we recommend the use of [`tf.keras.layers.Layer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/layers/Layer)
instead.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `trainable` | Boolean, whether the layer's variables should be trainable. |
| `name` | String name of the layer. |
| `dtype` | Default dtype of the layer's weights (default of `None` means use the type of the first input). |

<br />

Read-only properties:
name: The name of the layer (string).
dtype: Default dtype of the layer's weights (default of `None` means use
the type of the first input).
trainable_variables: List of trainable variables.
non_trainable_variables: List of non-trainable variables.
variables: List of all variables of this layer, trainable and
non-trainable.
updates: List of update ops of this layer.
losses: List of losses added by this layer.
trainable_weights: List of variables to be included in backprop.
non_trainable_weights: List of variables that should not be
included in backprop.
weights: The concatenation of the lists trainable_weights and
non_trainable_weights (in this order).

<br />

<br />

<br />

| ## Mutable properties ||
|---|---|
| `trainable` | Whether the layer should be trained (boolean). |
| `input_spec` | Optional (list of) `InputSpec` object(s) specifying the constraints on inputs that can be accepted by the layer. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `graph` | <br /> <br /> |
| `scope_name` | <br /> <br /> |

<br />

## Methods

### `apply`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/legacy_tf_layers/base.py#L239-L240)

    apply(
        *args, **kwargs
    )

### `get_losses_for`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/engine/base_layer_v1.py#L1467-L1484)

    get_losses_for(
        inputs
    )

Retrieves losses relevant to a specific set of inputs.

<br />

<br />

<br />

| Args ||
|---|---|
| `inputs` | Input tensor or list/tuple of input tensors. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| List of loss tensors of the layer that depend on `inputs`. ||

<br />

### `get_updates_for`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/engine/base_layer_v1.py#L1448-L1465)

    get_updates_for(
        inputs
    )

Retrieves updates relevant to a specific set of inputs.

<br />

<br />

<br />

| Args ||
|---|---|
| `inputs` | Input tensor or list/tuple of input tensors. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| List of update ops of the layer that depend on `inputs`. ||

<br />