ann_class2/tensorflow1.py - migrate from tensorflow version 1 to version 2
neoneye opened this issue · comments
Simon Strandgaard commented
I'm following the how to install guide of the data-science-linear-regression-in-python course.
The code for verifying that tensorflow is working correctly, didn't work for me, so I investigated how to fix it. Here is the error I was experiencing.
PROMPT> python3 tensorflow1.py
Traceback (most recent call last):
File "tensorflow1.py", line 20, in <module>
A = tf.placeholder(tf.float32, shape=(5, 5), name='A')
AttributeError: module 'tensorflow' has no attribute 'placeholder'
On TF's website there is a migration guide.
Change from
import tensorflow as tf
Change to
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
This solved it for me.
LazyProgrammer.me commented
Please use the course Q&A for course-related questions