tensorflow eager模块出错

问题描述 投票:3回答:3

我的操作系统是Ubuntu 16.04

Python版本是3.5

Tensorflow版本是14.0

当我尝试TF Eager模块的简单代码时

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

我有

AttributeError:模块'tensorflow.contrib.eager'没有属性'enable_eager_execution'

那有什么不对?

tensorflow
3个回答
5
投票

来自Eager user guide

急切执行不包含在TensorFlow的最新版本(1.4版)中。要使用它,您需要从源构建TensorFlow或安装每晚构建。

尝试安装Tensorflow的每晚构建而不是1.4.0。


0
投票

正如@Sunreef指出的那样,你应该安装tensorflow的夜间工件,以便使用TensorFlow eager模式。这是一个新的实验性功能,尚未包含在发行版中。

要安装每晚pip包,请执行以下操作:

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

还有夜间docker / nvidia-docker图像,提供Jupyter Notebook界面。

# 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

有关详细信息,请参阅this page


0
投票

从版本1.8开始,Tensorflow增加了Eager执行模式。所以需要更新。此外,它是一个相对较新的功能,有许多故障和频繁更新,因此建议使用最适合您的版本。尝试

conda update tensorflow

或者用pip

pip install --upgrade Tensorflow
© www.soinside.com 2019 - 2024. All rights reserved.