<s> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> import os <EOL> import cPickle <EOL> import numpy as np <EOL> import theano <EOL> floatX = theano . config . floatX <EOL> from pynet . utils . mnist_ubyte import read_mnist_images <EOL> from pynet . utils . mnist_ubyte import read_mnist_labels <EOL> from pynet . datasets . dataset import SingleBlock <EOL> class Cifar10 ( SingleBlock ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> im_dir = os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> self . label_names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . img_shape = ( <NUM_LIT:3> , <NUM_LIT:32> , <NUM_LIT:32> ) <EOL> self . img_size = np . prod ( self . img_shape ) <EOL> self . n_classes = <NUM_LIT:10> <EOL> fnames = [ '<STR_LIT>' % i for i in range ( <NUM_LIT:1> , <NUM_LIT:6> ) ] <EOL> X = [ ] <EOL> y = [ ] <EOL> for fname in fnames : <EOL> data_path = im_dir + fname <EOL> with open ( data_path ) as fin : <EOL> data_batch = cPickle . load ( fin ) <EOL> X . extend ( data_batch [ '<STR_LIT:data>' ] . tolist ( ) ) <EOL> y . extend ( data_batch [ '<STR_LIT>' ] ) <EOL> X_npy = np . array ( X , dtype = floatX ) <EOL> y_npy = np . zeros ( ( len ( y ) , <NUM_LIT:10> ) , dtype = floatX ) <EOL> for i in xrange ( len ( y ) ) : <EOL> y_npy [ i , y_npy [ i ] ] = <NUM_LIT:1> <EOL> super ( Cifar10 , self ) . __init__ ( X = X_npy , y = y_npy , ** kwargs ) </s>
