Just installed tensorflow-gpu 1.10 on Win10 using Python 3.6.6 and CUDA 9.0 Trying the sample code at https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/notebooks/custom_training.ipynb#scrollTo=_WRu7Pze7wk8
Problems right at the top:
class Model(object): def __init__(self):
# Initialize variable to (5.0, 0.0)
# In practice, these should be initialized to random values.
self.W = tf.Variable(5.0)
self.b = tf.Variable(0.0)
def __call__(self, x):
return self.W * x + self.b model = Model()
assert model(3.0).numpy() == 15.0
When run on Google Notebook it fails with
RuntimeError: tf.Variable not supported when eager execution is enabled. Please use tf.contrib.eager.Variable instead
You should fix that. With it fixed, the code runs without error on Notebook.
However when I copy it to a local .py file and run that, I get this really unexpected error:
Traceback (most recent call last): File "linear.py", line 15, in assert model(3.0).numpy() == 15.0 AttributeError: 'Tensor' object has no attribute 'numpy'
However in Python's interactive mode...
>>> import tensorflow as tf
>>> tf.enable_eager_execution()
>>> v = tf.contrib.eager.Variable(4.7)
>>> print( v.numpy() )
4.7
>>>
What gives?? (please bear in mind that I am a total Python and tensorflow noob)