【问题标题】:Installing TensorFlow examples in EC2 Instance在 EC2 实例中安装 TensorFlow 示例
【发布时间】:2017-07-08 04:28:10
【问题描述】:

我目前在 Amazon EC2 实例上运行,并尝试在 Jupyter Notebook (Python 2.7) 中运行以下代码:

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/")
images, labels = mnist.train.images, mnist.train.labels
images = images.reshape((55000,28,28))
np.savez_compressed("MNIST_data/train", images=images, labels=labels)

但是,我收到以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-de596f1c663d> in <module>()
      1 
----> 2 from tensorflow.examples.tutorials.mnist import input_data
      3 mnist = input_data.read_data_sets("MNIST_data/")
      4 images, labels = mnist.train.images, mnist.train.labels
      5 images = images.reshape((55000,28,28))

ImportError: No module named tensorflow.examples.tutorials.mnist

到目前为止,我还没有安装任何库来让 TensorFlow 代码工作(而且我不确定为什么我不需要安装任何东西)。如何安装此示例集?

【问题讨论】:

    标签: python amazon-web-services amazon-ec2 tensorflow


    【解决方案1】:

    我建议使用安装了 TensorFlow(以及其他 MachineLearning 软件包)的 AWS DeepLearning AMI。

    深度学习 Amazon Linux AMI 的 AMI ID 如下:
    us-east-1: ami-4b44745d
    us-east-2: ami-305d7c55
    us-west-2: ami-296e7850
    eu-west-1: ami-d36386aa
    ap-southeast-2:ami-52332031
    ap-northeast-1: ami-b44050d3
    ap-northeast-2:ami-1523fc7b

    发布用于 DW 框架的标签/分支:
    MXNet:v0.10.0 标签
    TensorFlow:v1.1.0 标签
    Theano:rel-0.8.2 标签
    Caffe : rc5 标签
    Caffe2:v0.7.0
    Keras:1.2.2 标签
    CNTK : v2.0.rc1 标签
    火炬:主分支

    查看description了解更多信息

    【讨论】:

      【解决方案2】:

      嗯,以下,

      from tensorflow.examples.tutorials.mnist import input_data
      mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
      

      应该可以,我只是仔细检查了一遍。也许您安装了一个非常旧的 TensorFlow 版本?您可以通过

      查看版本
      import tensorflow as tf
      tf.__version__
      

      我不记得input_data 何时添加到tensorflow.examples.tutorials.mnist,但它应该适用于 Tf 1.1 和 1.2

      【讨论】:

      • 嗨,塞巴斯蒂安——感谢您的快速回答。运行版本检查会返回“没有名为 Tensorflow 的模块”错误。事实证明,我的 Amazon 实例预装了 Theano,但没有预装 TensorFlow。你知道我会怎么做才能在我的实例中安装 TensorFlow 和 Python 2.7?
      • 我通常在 Ubuntu 实例中使用自己的 AMI,但我不知道他们是如何设置的。但是,如果幸运的话,它可以像从命令行执行 pip install tensorflow-gpu 一样简单。或者,您可以尝试其他答案中提到的 DL AMI。或者,如果您想自己在 AWS 上设置 DL 实例/AMI,这里将提供分步指南:sebastianraschka.com/pdf/books/dlb/…
      猜你喜欢
      • 2020-11-29
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 2021-09-17
      • 1970-01-01
      相关资源
      最近更新 更多