tf.experimental.output_all_intermediates
Stay organized with collections
Save and categorize content based on your preferences.
Whether to output all intermediates from functional control flow ops.
tf.experimental.output_all_intermediates(
state
)
The "default" behavior to is to output all intermediates when using v2 control
flow inside Keras models in graph mode (possibly inside Estimators). This is
needed to support taking gradients of v2 control flow. In graph mode, Keras
can sometimes freeze the forward graph before the gradient computation which
does not work for v2 control flow since it requires updating the forward ops
to output the needed intermediates. We work around this by proactively
outputting the needed intermediates when building the forward pass itself.
Ideally any such extra tensors should be pruned out at runtime. However, if
for any reason this doesn't work for you or if you have an infernce-only model
you can turn this behavior off using
tf.compat.v1.experimental.output_all_intermediates(False)
.
If with the default behavior you are still seeing errors of the form
"Connecting to invalid output X of source node Y which has Z outputs" try
setting tf.compat.v1.experimental.output_all_intermediates(True)
and
please file an issue at https://github.com/tensorflow/tensorflow/issues.
Args |
state
|
True, False or None. None restores the default behavior.
|
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.experimental.output_all_intermediates\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/control_flow_v2_toggles.py#L70-L94) |\n\nWhether to output all intermediates from functional control flow ops.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.experimental.output_all_intermediates`](/api_docs/python/tf/compat/v1/experimental/output_all_intermediates)\n\n\u003cbr /\u003e\n\n tf.experimental.output_all_intermediates(\n state\n )\n\nThe \"default\" behavior to is to output all intermediates when using v2 control\nflow inside Keras models in graph mode (possibly inside Estimators). This is\nneeded to support taking gradients of v2 control flow. In graph mode, Keras\ncan sometimes freeze the forward graph before the gradient computation which\ndoes not work for v2 control flow since it requires updating the forward ops\nto output the needed intermediates. We work around this by proactively\noutputting the needed intermediates when building the forward pass itself.\nIdeally any such extra tensors should be pruned out at runtime. However, if\nfor any reason this doesn't work for you or if you have an infernce-only model\nyou can turn this behavior off using\n[`tf.compat.v1.experimental.output_all_intermediates(False)`](../../tf/experimental/output_all_intermediates).\n\nIf with the default behavior you are still seeing errors of the form\n\"Connecting to invalid output X of source node Y which has Z outputs\" try\nsetting [`tf.compat.v1.experimental.output_all_intermediates(True)`](../../tf/experimental/output_all_intermediates) and\nplease file an issue at https://github.com/tensorflow/tensorflow/issues.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|----------------------------------------------------------|\n| `state` | True, False or None. None restores the default behavior. |\n\n\u003cbr /\u003e"]]