“module 'tensorflow' has no attribute 'placeholder” Code Answer’s

When you are trying to access anything which has no occurrence from any object, you can get Attribute Error. It is caused when incompatible code is used with the installed TensorFlow library.

We will try to make it easy for you. When you have already installed TensorFlow 2.0 or higher version but your code is compatible with TensorFlow 1.0 version, it will cause AttributeError.

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

on Jan 01, 1970
#replace import tensorflow as tf by following
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Add Comment

0

module 'tensorflow' has no attribute 'placeholder' tf 2.0

on Jan 01, 1970
change the <tf.placeholder> as <tf.compat.v1.placeholder>

such as

x = tf.placeholder(shape = [None, image_pixels], dtype = tf.float32)
change as

x = tf.compat.v1.placeholder(shape = [None, image_pixels], dtype = tf.float32)
but there would be another problem about runtime error with eager execution add <tf.compat.v1.disable_eager_execution()> after import part

import tensorflow as tf
tf.compat.v1.disable_eager_execution()

Add Comment

0

AttributeError: module 'tensorflow' has no attribute 'placeholder' site:stackoverflow.com

on Jan 01, 1970
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Add Comment

0

You have seen what you can do to solve the problem. If we helped you, please consider sharing this post to help us gain a wider audience.

Thank you and Keep searching Codeprozone.

Python answers related to "attributeerror: module 'tensorflow' has no attribute 'placeholder'"

View All Python queries

Python queries related to "attributeerror: module 'tensorflow' has no attribute 'placeholder'"

Browse Other Code Languages

CodeProZone