Disables TensorFlow 2.x behaviors. This function can be called at the beginning of the program (before `Tensors`, `Graphs` or other structures have been created, and before devices have been initialized. It switches all global behaviors that are different between TensorFlow 1.x and 2.x to b
()
| 53 | |
| 54 | @tf_export(v1=["disable_v2_behavior"]) |
| 55 | def disable_v2_behavior(): |
| 56 | """Disables TensorFlow 2.x behaviors. |
| 57 | |
| 58 | This function can be called at the beginning of the program (before `Tensors`, |
| 59 | `Graphs` or other structures have been created, and before devices have been |
| 60 | initialized. It switches all global behaviors that are different between |
| 61 | TensorFlow 1.x and 2.x to behave as intended for 1.x. |
| 62 | |
| 63 | User can call this function to disable 2.x behavior during complex migrations. |
| 64 | """ |
| 65 | tf2.disable() |
| 66 | ops.disable_eager_execution() |
| 67 | tensor_shape.disable_v2_tensorshape() # Also switched by tf2 |
| 68 | variable_scope.disable_resource_variables() |
| 69 | ops.disable_tensor_equality() |
| 70 | # Disables TensorArrayV2 and control flow V2. |
| 71 | control_flow_v2_toggles.disable_control_flow_v2() |