tf.contrib.checkpoint.List
Stay organized with collections
Save and categorize content based on your preferences.
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
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
.
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
.
Attributes |
layers
|
|
losses
|
Aggregate losses from any Layer instances.
|
non_trainable_variables
|
|
non_trainable_weights
|
|
trainable
|
|
trainable_variables
|
|
trainable_weights
|
|
updates
|
Aggregate updates from any Layer instances.
|
variables
|
|
weights
|
|
Methods
append
View source
append(
value
)
Add a new trackable value.
copy
View source
copy()
count
count(
value
)
S.count(value) -> integer -- return number of occurrences of value
extend
View source
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
__add__(
other
)
__contains__
__contains__(
value
)
__eq__
View source
__eq__(
other
)
Return self==value.
__getitem__
View source
__getitem__(
key
)
__iter__
__iter__()
__len__
View source
__len__()
__mul__
View source
__mul__(
n
)
__radd__
View source
__radd__(
other
)
__rmul__
View source
__rmul__(
n
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.checkpoint.List\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L253-L369) |\n\nAn append-only sequence type which is trackable. \n\n tf.contrib.checkpoint.List(\n *args, **kwargs\n )\n\nMaintains checkpoint dependencies on its contents (which must also be\ntrackable), and forwards any `Layer` metadata such as updates and losses.\n\nNote that `List` is purely a container. It lets a [`tf.keras.Model`](../../../tf/keras/Model) or\nother trackable object know about its contents, but does not call any\n`Layer` instances which are added to it. To indicate a sequence of `Layer`\ninstances which should be called sequentially, use [`tf.keras.Sequential`](../../../tf/keras/Sequential).\n\n#### Example usage:\n\n class HasList(tf.keras.Model):\n\n def __init__(self):\n super(HasList, self).__init__()\n self.layer_list = tf.contrib.checkpoint.List([layers.Dense(3)])\n self.layer_list.append(layers.Dense(4))\n\n def call(self, x):\n aggregation = 0.\n for l in self.layer_list:\n x = l(x)\n aggregation += tf.reduce_sum(x)\n return aggregation\n\nThis kind of wrapping is necessary because `Trackable` objects do not\n(yet) deeply inspect regular Python data structures, so for example assigning\na regular list (`self.layer_list = [layers.Dense(3)]`) does not create a\ncheckpoint dependency and does not add the `Layer` instance's weights to its\nparent `Model`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|---------------------------|-----------------------------------------------|\n| `layers` | \u003cbr /\u003e \u003cbr /\u003e |\n| `losses` | Aggregate losses from any `Layer` instances. |\n| `non_trainable_variables` | \u003cbr /\u003e \u003cbr /\u003e |\n| `non_trainable_weights` | \u003cbr /\u003e \u003cbr /\u003e |\n| `trainable` | \u003cbr /\u003e \u003cbr /\u003e |\n| `trainable_variables` | \u003cbr /\u003e \u003cbr /\u003e |\n| `trainable_weights` | \u003cbr /\u003e \u003cbr /\u003e |\n| `updates` | Aggregate updates from any `Layer` instances. |\n| `variables` | \u003cbr /\u003e \u003cbr /\u003e |\n| `weights` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `append`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L317-L320) \n\n append(\n value\n )\n\nAdd a new trackable value.\n\n### `copy`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L296-L297) \n\n copy()\n\n### `count`\n\n count(\n value\n )\n\nS.count(value) -\\\u003e integer -- return number of occurrences of value\n\n### `extend`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L322-L325) \n\n extend(\n values\n )\n\nAdd a sequence of trackable values.\n\n### `index`\n\n index(\n value, start=0, stop=None\n )\n\nS.index(value, \\[start, \\[stop\\]\\]) -\\\u003e integer -- return first index of value.\nRaises ValueError if the value is not present.\n\nSupporting start and stop arguments is optional, but\nrecommended.\n\n### `__add__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L331-L332) \n\n __add__(\n other\n )\n\n### `__contains__`\n\n __contains__(\n value\n )\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L247-L250) \n\n __eq__(\n other\n )\n\nReturn self==value.\n\n### `__getitem__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L356-L357) \n\n __getitem__(\n key\n )\n\n### `__iter__`\n\n __iter__()\n\n### `__len__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L362-L363) \n\n __len__()\n\n### `__mul__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L347-L348) \n\n __mul__(\n n\n )\n\n### `__radd__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L353-L354) \n\n __radd__(\n other\n )\n\n### `__rmul__`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/training/tracking/data_structures.py#L350-L351) \n\n __rmul__(\n n\n )"]]