Run into the following issue: build_tensor_flow is not supported in Eager Mode Run into the following issue: build_tensor_flow is not supported in Eager Mode python-3.x python-3.x

Run into the following issue: build_tensor_flow is not supported in Eager Mode


Is because you are using tensorflow v2. You have to use the tensorflow v2 compatibility and disable eager mode.

Be careful with the tensorflow imports that you use, for example if you use tensorflow_core, be sure that you are using all the dependencies from "tensorflow".You have to add before your code:

import tensorflow as tfif tf.executing_eagerly():   tf.compat.v1.disable_eager_execution()


Ran into that exact same problem when compiling that code from LinkedIn Learning for exporting the Keras model that was written using TensorFlow 1.x API. After replacing everything with the equivalent tf.compat.v1 functions, such as changing

model_builder = tf.saved_model.builder.SavedModelBuilder("exported_model")

to

model_builder = tf.compat.v1.saved_model.Builder("exported_model")

and disables eager execution as suggested above by Cristian Zumelzu, the code was able to run fine with the expected warnings about the deprecated functions.