【问题标题】:Error in tensorflow eager module张量流急切模块中的错误
【发布时间】:2019-03-28 23:16:16
【问题描述】:

我的操作系统是 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


    【解决方案1】:

    来自渴望user guide

    TensorFlow 的最新版本(1.4 版)中不包含 Eager Execution。要使用它,您需要从源代码构建 TensorFlow 或安装每晚构建版本。

    尝试安装 Tensorflow 的夜间版本而不是 1.4.0。

    【讨论】:

      【解决方案2】:

      正如@Sunreef 所指出的,您应该安装 tensorflow 的夜间工件,以便使用 TensorFlow 急切模式。这是一个新的实验性功能,尚未包含在版本中。

      要安装 nightly 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

      【讨论】:

        【解决方案3】:

        从 1.8 版开始,Tensorflow 中添加了急切执行模式。所以更新是必要的。此外,它是一个相对较新的功能,故障较多且更新频繁,因此建议使用适合您的最新版本。 试试

        conda update tensorflow
        

        或者用点子

        pip install --upgrade Tensorflow
        

        【讨论】:

          猜你喜欢
          • 2023-04-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-12-01
          • 1970-01-01
          • 2018-06-21
          相关资源
          最近更新 更多