I decided to try TensorFlow, and when I ran it, I got the following error ...
AttributeError: module 'tensorflow' has no attribute 'constant'
The executed file is as follows.
tensorflow.py
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
1st line
It says ʻimport tensorflow as tf. Because the file name is
tensorflow.py`
It seems that it was an error that there was no'constant' because I was importing my own file instead of tensorflow of the library.
So ** Rename the file and it will work! ** **
$ python tensorflowrun.py
Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)
Rename it to something other than tensorflow.py.
Those who touch Python for the first time or those who touch Python for the first time in a long time may want to doubt the file name if this happens.
Recommended Posts