tf.contrib.checkpoint.NoDependency
Stay organized with collections
Save and categorize content based on your preferences.
Allows attribute assignment to Trackable
objects with no dependency.
tf.contrib.checkpoint.NoDependency(
value
)
Example usage:
obj = Trackable()
obj.has_dependency = tf.Variable(0., name="dep")
obj.no_dependency = NoDependency(tf.Variable(1., name="nodep"))
assert obj.no_dependency.name == "nodep:0"
obj
in this example has a dependency on the variable "dep", and both
attributes contain un-wrapped Variable
objects.
NoDependency
also works with tf.keras.Model
, but only for checkpoint
dependencies: wrapping a Layer
in NoDependency
will assign the (unwrapped)
Layer
to the attribute without a checkpoint dependency, but the Model
will
still track the Layer
(so it will appear in Model.layers
, and its
variables will appear in Model.variables
).
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.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.checkpoint.NoDependency\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#L41-L63) |\n\nAllows attribute assignment to `Trackable` objects with no dependency. \n\n tf.contrib.checkpoint.NoDependency(\n value\n )\n\n#### Example usage:\n\n obj = Trackable()\n obj.has_dependency = tf.Variable(0., name=\"dep\")\n obj.no_dependency = NoDependency(tf.Variable(1., name=\"nodep\"))\n assert obj.no_dependency.name == \"nodep:0\"\n\n`obj` in this example has a dependency on the variable \"dep\", and both\nattributes contain un-wrapped `Variable` objects.\n\n`NoDependency` also works with [`tf.keras.Model`](../../../tf/keras/Model), but only for checkpoint\ndependencies: wrapping a `Layer` in `NoDependency` will assign the (unwrapped)\n`Layer` to the attribute without a checkpoint dependency, but the `Model` will\nstill track the `Layer` (so it will appear in [`Model.layers`](/api_docs/python/tf/keras/Model#layers), and its\nvariables will appear in `Model.variables`)."]]