Tensorflow:在Python 3.5中读取MNIST数据

时间:2017-02-22 13:55:52

标签: python tensorflow neural-network mnist

我刚刚开始使用ML和Tensorflow。 (我认为)在我的ubuntu系统上成功安装了tensorflow之后。我想用手写的数据实现具有张量流的CNN。如果已经在stackoverflow中阅读了几个问题并且在没有任何解决方案的情况下被愚弄了大约2天。

    import tensorflow as tf
    import matplotlib.pyplot as plt
    import struct
    import numpy as np
    from mpl_toolkits.mplot3d import Axes3D

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

    mnist = MNIST("./data/")   

    # for now i just wanna print something that tells me i successfully   
    # read the data
    print("Size of:")
    print("- Training-set:\t\t{}".format(len(data.train.labels)))
    print("- Test-set:\t\t{}".format(len(data.test.labels)))
    print("- Validation-set:\t{}".format(len(data.validation.labels)))

我得到的是:

    ---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
<ipython-input-3-17f8ae55d032> in <module>()
      7 
      8 # Import MNIST data
----> 9 from tensorflow.examples.tutorials.mnist import input_data
     10 data = input_data.read_data_sets("./MNIST/", one_hot=True)
     11 

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/examples/tutorials/mnist/__init__.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 from tensorflow.examples.tutorials.mnist import input_data
     22 from tensorflow.examples.tutorials.mnist import mnist

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/examples/tutorials/mnist/input_data.py in <module>()
     27 from six.moves import xrange  # pylint: disable=redefined-builtin
     28 import tensorflow as tf
---> 29 from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/__init__.py in <module>()
     23 from tensorflow.contrib import copy_graph
     24 from tensorflow.contrib import crf
---> 25 from tensorflow.contrib import cudnn_rnn
     26 from tensorflow.contrib import distributions
     27 from tensorflow.contrib import factorization

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/cudnn_rnn/__init__.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 from tensorflow.contrib.cudnn_rnn.python.ops.cudnn_rnn_ops import CudnnGRU
     22 from tensorflow.contrib.cudnn_rnn.python.ops.cudnn_rnn_ops import CudnnLSTM
     23 from tensorflow.contrib.cudnn_rnn.python.ops.cudnn_rnn_ops import CudnnRNNRelu

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py in <module>()
     26 
     27 _cudnn_rnn_ops_so = loader.load_op_library(
---> 28     resource_loader.get_path_to_datafile("_cudnn_rnn_ops.so"))
     29 
     30 _cudnn_rnn_common_doc_string = """

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/util/loader.py in load_op_library(path)
     40   if os.name != 'nt':
     41     path = resource_loader.get_path_to_datafile(path)
---> 42     ret = load_library.load_op_library(path)
     43     assert ret, 'Could not load %s' % path
     44     return ret

/home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/load_library.py in load_op_library(library_filename)
     62       # pylint: disable=protected-access
     63       raise errors_impl._make_specific_exception(
---> 64           None, None, error_msg, error_code)
     65       # pylint: enable=protected-access
     66   finally:

NotFoundError: /home/vanmunky/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/cudnn_rnn/python/ops/_cudnn_rnn_ops.so: cannot open shared object file: No such file or directory

我几乎可以肯定4 gz文件位于错误的位置,但我几乎无处不在。那么根据这段代码我究竟要把数据放在哪里?或者代码错了?我错过了什么?

由于

0 个答案:

没有答案