title: How to read serialized data by python2 cPikle with python3 pickle?
body: <p>I'm trying to work with <a href="http://www.cs.toronto.edu/~kriz/cifar.html" rel="nofollow">CIFAR-10 dataset</a> which contains <a href="http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz" rel="nofollow">a special version for python</a>.</p>
  
  <p>It is a set of binary files, each representing a dictionary of 10k numpy matrices. The files were obviously created by python2 <code>cPickle</code>.</p>
  
  <p>I tried to load it from python2 as follows:</p>
  
  <pre><code>import cPickle
  with open("data/data_batch_1", "rb") as f:
      data = cPickle.load(f)
  </code></pre>
  
  <p>This works really great. However, if I try to load the data from python3 (that hasn't <code>cPickle</code> but <code>pickle</code> instead), it fails:</p>
  
  <pre><code>import pickle
  with open("data/data_batch_1", "rb") as f:
      data = pickle.load(f)
  </code></pre>
  
  <p>If fails with the following error:</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6: ordinal not in range(128)
  </code></pre>
  
  <p>Can I somehow transform the ofiginal dataset into new one that will be readable from python3? Or may I somehow read it from python3 direrctly?</p>
  
  <p>I've tried loading it by <code>cPickle</code>, dumping it into <code>json</code> and reading it back by <code>pickle</code>, but numpy matrices obviously can't be written as a json file.</p>