# tf.contrib.checkpoint.List

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L253-L369) |

An append-only sequence type which is trackable.

    tf.contrib.checkpoint.List(
        *args, **kwargs
    )

Maintains checkpoint dependencies on its contents (which must also be
trackable), and forwards any `Layer` metadata such as updates and losses.

Note that `List` is purely a container. It lets a [`tf.keras.Model`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/Model) or
other trackable object know about its contents, but does not call any
`Layer` instances which are added to it. To indicate a sequence of `Layer`
instances which should be called sequentially, use [`tf.keras.Sequential`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/Sequential).

#### Example usage:

    class HasList(tf.keras.Model):

      def __init__(self):
        super(HasList, self).__init__()
        self.layer_list = tf.contrib.checkpoint.List([layers.Dense(3)])
        self.layer_list.append(layers.Dense(4))

      def call(self, x):
        aggregation = 0.
        for l in self.layer_list:
          x = l(x)
          aggregation += tf.reduce_sum(x)
        return aggregation

This kind of wrapping is necessary because `Trackable` objects do not
(yet) deeply inspect regular Python data structures, so for example assigning
a regular list (`self.layer_list = [layers.Dense(3)]`) does not create a
checkpoint dependency and does not add the `Layer` instance's weights to its
parent `Model`.

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `layers` | <br /> <br /> |
| `losses` | Aggregate losses from any `Layer` instances. |
| `non_trainable_variables` | <br /> <br /> |
| `non_trainable_weights` | <br /> <br /> |
| `trainable` | <br /> <br /> |
| `trainable_variables` | <br /> <br /> |
| `trainable_weights` | <br /> <br /> |
| `updates` | Aggregate updates from any `Layer` instances. |
| `variables` | <br /> <br /> |
| `weights` | <br /> <br /> |

<br />

## Methods

### `append`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L317-L320)

    append(
        value
    )

Add a new trackable value.

### `copy`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L296-L297)

    copy()

### `count`

    count(
        value
    )

S.count(value) -\> integer -- return number of occurrences of value

### `extend`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L322-L325)

    extend(
        values
    )

Add a sequence of trackable values.

### `index`

    index(
        value, start=0, stop=None
    )

S.index(value, \[start, \[stop\]\]) -\> integer -- return first index of value.
Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but
recommended.

### `__add__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L331-L332)

    __add__(
        other
    )

### `__contains__`

    __contains__(
        value
    )

### `__eq__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L247-L250)

    __eq__(
        other
    )

Return self==value.

### `__getitem__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L356-L357)

    __getitem__(
        key
    )

### `__iter__`

    __iter__()

### `__len__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L362-L363)

    __len__()

### `__mul__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L347-L348)

    __mul__(
        n
    )

### `__radd__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L353-L354)

    __radd__(
        other
    )

### `__rmul__`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L350-L351)

    __rmul__(
        n
    )