AttributeError module tensorflow has no attribute constant

0 votes

I installed tensorflow in my system. I am able to import tensorflow module. But when I try to call constant function, it throws me the below error.

import tensorflow as tf
hello = tf.constant(10)
AttributeError: module 'tensorflow' has no attribute 'constant'
Apr 21, 2020 in Machine Learning by akhtar
• 38,180 points
7,021 views

1 answer to this question.

0 votes

Hi@akhtar,

There may be problem in the versions. You can follow the below steps to avoid this kind of error.

$ pip uninstall tensorflow -y

$ pip uninstall tensorflow-gpu -y

$ pip uninstall tensorboard -y

$ pip install --upgrade tensorflow-gpu==1.9.0 -y

Hope this will help you.

answered Apr 21, 2020 by MD
• 95,140 points

Related Questions In Machine Learning

0 votes
1 answer

AttributeError: module 'tensorflow' has no attribute 'estimator'.

Hi@akhtar, There was an environment issue, tensorflow was ...READ MORE

answered Apr 23, 2020 in Machine Learning by MD
• 95,140 points
1,119 views
0 votes
1 answer

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

Hi@akhtar, In Tensorflow 2.0, there is no placeholder. ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,140 points
1,364 views
0 votes
1 answer

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

Hi@akhtar, In Tensorflow 2.0, there is no attribute named ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,140 points
2,431 views
0 votes
1 answer

AttributeError: module 'matplotlib' has no attribute 'scatter'

Hi@akhtar, To avoid this error, make sure you ...READ MORE

answered Apr 16, 2020 in Machine Learning by MD
• 95,140 points
3,806 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,978 views
0 votes
0 answers
0 votes
0 answers

Hello I have some errors while implementing variational autoencoder

def dense_layers(sizes): return tfk.Sequential([tfkl.Dense(size, ...READ MORE

May 18, 2019 in Machine Learning by anonymous

edited May 20, 2019 by Omkar 616 views
0 votes
1 answer

AttributeError: module 'tensorflow.compat' has no attribute 'v1'

Hi@Usman, It seems you are using an older ...READ MORE

answered Jul 18, 2020 in Machine Learning by MD
• 95,140 points
2,044 views
0 votes
1 answer

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

Hi@akhtar, Tensorflow 2.0 has eager_execution enabled by default and ...READ MORE

answered Apr 21, 2020 in Machine Learning by MD
• 95,140 points
1,003 views