Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in tensorflow eager module

Tags:

tensorflow

My OS is Ubuntu 16.04

Python version is 3.5

Tensorflow version is 14.0

When I tried a simple code for TF Eager module

import tensorflow as tf
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
x = [[2.]]
m = tf.matmul(x, x)

I got

AttributeError: module 'tensorflow.contrib.eager' has no attribute 'enable_eager_execution'

So what's wrong?

like image 665
Hemp Avatar asked Nov 07 '17 08:11

Hemp


3 Answers

From Eager user guide:

Eager execution is not included in the latest release (version 1.4) of TensorFlow. To use it, you will need to build TensorFlow from source or install the nightly builds.

Try to install the nightly build of Tensorflow instead of 1.4.0.

like image 158
Sunreef Avatar answered Oct 14 '22 02:10

Sunreef


As @Sunreef pointed out, you should install the nightly artifacts of tensorflow in order to use TensorFlow eager mode. It is a new, experimental feature that is not yet included in the releases.

To install the nightly pip packages, do:

# For CPU only
pip install tf-nightly  
# For GPU support
pip install tf-nightly-gpu

There are also nightly docker/nvidia-docker images available, offering a Jupyter Notebook interface.

# If you have a GPU, use https://github.com/NVIDIA/nvidia-docker
nvidia-docker pull tensorflow/tensorflow:nightly-gpu
nvidia-docker run -it -p 8888:8888 tensorflow/tensorflow:nightly-gpu

# If you do not have a GPU, use the CPU-only image
docker pull tensorflow/tensorflow:nightly
docker run -it -p 8888:8888 tensorflow/tensorflow:nightly

See this page for more details.

like image 20
Shanqing Cai Avatar answered Oct 14 '22 02:10

Shanqing Cai


Eager execution mode was added to Tensorflow starting with version 1.8. So an update is necessary. In addition, it is a relatively new feature with many glitches and frequent updates, so using the most recent version that can work for you is recommended. Try

conda update tensorflow

or with pip

pip install --upgrade Tensorflow
like image 1
Ali Hummos Avatar answered Oct 14 '22 02:10

Ali Hummos