Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 610
Jelly Wu Avatar asked Oct 26 '19 20:10

Jelly Wu


1 Answers

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()

like image 57
Djib2011 Avatar answered Oct 08 '22 17:10

Djib2011