Reputation:
I have used tensor-flow for ONE day, but there come some troubles, when I import tensor-flow, there would be AttributeError: 'module' object has no attribute 'variable'
I use Windows10, Python 3.5.3, Anaconda-3 4.4.0
here is my test code:
import tensorflow as tf
my_var = tf.Variable(tf.linspace(10.0, 13.0, 4))
with tf.Session() as sess:
print (sess.run(my_var))
I got this error:
Upvotes: 2
Views: 6101
Reputation: 11
Replace 'variable' with 'Variable', for example following code gives error:
initial_value=tf.random.normal(shape=(2,2))
a = tf.variable(initial_value)
print(a)
but this code gives successful output
initial_value=tf.random.normal(shape=(2,2))
a = tf.Variable(initial_value)
print(a)
Upvotes: 1
Reputation: 3056
It looks like you have written a module, random.py
, which shadows the standard library's random module. Try renaming the file and check if the error goes away. You can tell it's importing your random.py at the bottom of the stacktrace you posted.
Upvotes: 0