Sets summary recording on or off per the provided boolean value. The provided value can be a python boolean, a scalar boolean Tensor, or or a callable providing such a value; if a callable is passed it will be invoked on-demand to determine whether summary writing will occur. Args: con
(condition)
| 100 | @tf_export("summary.record_if", v1=[]) |
| 101 | @tf_contextlib.contextmanager |
| 102 | def record_if(condition): |
| 103 | """Sets summary recording on or off per the provided boolean value. |
| 104 | |
| 105 | The provided value can be a python boolean, a scalar boolean Tensor, or |
| 106 | or a callable providing such a value; if a callable is passed it will be |
| 107 | invoked on-demand to determine whether summary writing will occur. |
| 108 | |
| 109 | Args: |
| 110 | condition: can be True, False, a bool Tensor, or a callable providing such. |
| 111 | |
| 112 | Yields: |
| 113 | Returns a context manager that sets this value on enter and restores the |
| 114 | previous value on exit. |
| 115 | """ |
| 116 | old = context.context().summary_recording |
| 117 | try: |
| 118 | context.context().summary_recording = condition |
| 119 | yield |
| 120 | finally: |
| 121 | context.context().summary_recording = old |
| 122 | |
| 123 | |
| 124 | # TODO(apassos) consider how to handle local step here. |
no test coverage detected