Python3 Recognizes Tensorflow, but Doesn't Recognize Any of Its Attributes

I am getting the following errors:

AttributeError: module 'tensorflow' has no attribute 'variable_scope'
AttributeError: module 'tensorflow' has no attribute 'squared_difference'

tensorflow is installed:

>> pip3 list | grep tensorflow
tensorflow           2.0.0    
tensorflow-estimator 2.0.1

1 Answer

TensorFlow 2.0 cleaned up some of the APIs. Mathematical functions such as squared_difference() are now under tf.math.

There is no tf.variable_scope() in TensorFlow 2.0. I suggest reading this post with examples on how to migrate your code to TF2.

If you want your code to be compatible with older versions of TensorFlow, you can use tf.compat.v1.variable_scope()

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest