AttributeError: 'Sequential' object has no attribute 'run_eagerly
时间: 2023-10-25 21:09:26 浏览: 114
【Python】AttributeError: ‘AutoSchema’ object has no attribute ‘get_link’
5星 · 资源好评率100%
This error occurs when trying to use the `run_eagerly` method on a TensorFlow `Sequential` object. The `run_eagerly` method is used to enable eager execution, which is a mode of TensorFlow where operations are executed immediately as they are called, rather than being added to a computational graph to be executed later.
However, the `Sequential` object does not have a `run_eagerly` method, as it is a high-level API for building and training neural networks using TensorFlow. Instead, you can enable eager execution globally by calling `tf.config.experimental_run_functions_eagerly(True)` before defining and training your model.
Alternatively, you can use a lower-level API such as `tf.keras.Model` or `tf.keras.layers.Layer` to build your model, which do have a `run_eagerly` method.
阅读全文