AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'

22,773

Solution 1

Tensorflow 2.0 has eager_execution enabled by default and so there is no need for you to run tf.enable_eager_execution. Only if your running versions below 2.0 should you enable eager execution

Solution 2

Eager execution is enabled by default in version 2.x You can check that by using

tf.executing_eagerly()

It should return True. If you are having version less then 2.0 then it can be enabled by using

tf.enable_eager_execution()

Solution 3

for tensorflow v1.x code, this will works:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
tf.enable_eager_execution()

Solution 4

I got same error and many with version 2.0. Downgrading to 1.1X is not the solution.

Follow the instruction at https://github.com/tensorflow/tensorflow/issues/35749

Install latest visual C++. reboot your machine . It should work https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

Share:
22,773
venkatesh
Author by

venkatesh

Updated on August 07, 2021

Comments

  • venkatesh
    venkatesh almost 3 years

    I just tried to enable eager execution in my shell which is actually showing an error:

    AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'
    

    My Tensorflow version is 2.0

    The image shows my tensorflow version

    can anyone tell me why am I getting this...

    Thanks in advance

  • JEMS25
    JEMS25 about 4 years
    Tensorflow 2.1.0 is compiled using MSVC 2019, which appears to require an additional DLL. As per github.com/tensorflow/tensorflow/issues/36167