无法在 google 云 ml 上加载 mnist 数据集

Can't load mnist dataset on google cloud ml

我想在 google 云 ml 上 运行 MNIST 的简单深度学习模型。我尝试通过tensroflow的实用方法tensorflow.examples.tutorials.mnist下载并解压它。不幸的是,当我在云中使用它时,它对我的​​代码不可见。我有这样的异常:没有这样的文件或目录:'gs://bucket/path/train-images-idx3-ubyte.gz 当我浏览存储桶时,文件在那里,但 tensorflow 看不到它。

怎么了?

问题是我使用了tensorflow附带的reader,它只能与本地文件系统一起工作。为了阅读 mnist,你必须使用 tensorflow.python.lib.io 包。

遗憾的是,TensorFlow 的文件系统抽象无法正确支持 Python 的 gzip 库。因此,mnist.read_data_sets 仅支持本地文件系统上的 train_dir,即不能将 GCS 与实用程序函数一起使用。

解决方法是在本地文件系统上创建一个临时目录并改用它。

在我看来,这是示例中的默认设置,例如 mnist_softmax.py has a flag, --data-dir, that by default points to '/tmp/tensorflow/mnist/input_data'. To verify, I copied the contents of mnist_softmax.py into a new Python script which successfully ran on Cloud Machine Learning Engine. Also worked for mnist_deep.py

但是,如果您要手动使用 read_data_sets(通过 tensorflow/examples/tutorials/mnist/input_data.py),请务必将本地目录作为第一个参数传递。