IOError:[Errno套接字错误]发生了违反协议的EOF(_ssl.c:590)使用tensorflow load_dataset()访问MNIST数据库时出错

时间:2018-08-13 05:18:53

标签: python python-3.x python-2.7 tensorflow

我遇到了以下IOError:

IOError: [Errno socket error] EOF occurred in violation of protocol (_ssl.c:590) 
Error when accessing MNIST database using Python2.7 and tensorflow library @
mnist = tf.contrib.learn.datasets.load_dataset("mnist")

这是完整的堆栈跟踪:

File "./ML_cnn_mnist.py", line 71, in main
  mnist = tf.contrib.learn.datasets.load_dataset("mnist")
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 272, in new_func
  return func(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/__init__.py", line 80, in load_dataset
  return DATASETS[name]()
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 272, in new_func
  return func(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 300, in load_mnist
  return read_data_sets(train_dir)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 272, in new_func
  return func(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py", line 260, in read_data_sets
  source_url + TRAIN_IMAGES)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 272, in new_func
  return func(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 252, in maybe_download
  temp_file_name, _ = urlretrieve_with_retry(source_url)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 272, in new_func
  return func(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 205, in wrapped_fn
  return fn(*args, **kwargs)
File "/home/nidhi/TensorVirtualenv/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py", line 233, in urlretrieve_with_retry
  return urllib.request.urlretrieve(url, filename)
File "/usr/lib/python2.7/urllib.py", line 98, in urlretrieve
  return opener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
  fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 213, in open
  return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 443, in open_https
  h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
  self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
  self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 859, in send
  self.connect()
File "/usr/lib/python2.7/httplib.py", line 1278, in connect
  server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 353, in wrap_socket
  _context=self)
File "/usr/lib/python2.7/ssl.py", line 601, in __init__
  self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 830, in do_handshake
  self._sslobj.do_handshake()
IOError: [Errno socket error] EOF occurred in violation of protocol (_ssl.c:590)

这是我的代码:

def main(unused_argv):
  # Load training and eval data
  mnist = tf.contrib.learn.datasets.load_dataset("mnist")
  train_data = mnist.train.images # Returns np.array
  train_labels = np.asarray(mnist.train.labels, dtype=np.int32)
  eval_data = mnist.test.images # Returns np.array
  eval_labels = np.asarray(mnist.test.labels, dtype=np.int32)

有人可以为错误提出解决方案吗?

0 个答案:

没有答案