<s> """<STR_LIT>""" <EOL> __authors__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __credits__ = [ "<STR_LIT>" ] <EOL> __license__ = "<STR_LIT>" <EOL> __maintainer__ = "<STR_LIT>" <EOL> __email__ = "<STR_LIT>" <EOL> import numpy as np <EOL> from theano . compat . six . moves import xrange <EOL> from pylearn2 . datasets . dense_design_matrix import DenseDesignMatrix <EOL> class ArangeDataset ( DenseDesignMatrix ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , num_examples , * args , ** kwargs ) : <EOL> X = np . zeros ( ( num_examples , <NUM_LIT:1> ) ) <EOL> X [ : , <NUM_LIT:0> ] = np . arange ( num_examples ) <EOL> super ( ArangeDataset , self ) . __init__ ( X , * args , ** kwargs ) <EOL> def random_dense_design_matrix ( rng , num_examples , dim , num_classes ) : <EOL> """<STR_LIT>""" <EOL> X = rng . randn ( num_examples , dim ) <EOL> if num_classes : <EOL> Y = rng . randint ( <NUM_LIT:0> , num_classes , ( num_examples , <NUM_LIT:1> ) ) <EOL> y_labels = num_classes <EOL> else : <EOL> Y = None <EOL> y_labels = None <EOL> return DenseDesignMatrix ( X = X , y = Y , y_labels = y_labels ) <EOL> def random_one_hot_dense_design_matrix ( rng , num_examples , dim , num_classes ) : <EOL> X = rng . randn ( num_examples , dim ) <EOL> idx = rng . randint ( <NUM_LIT:0> , num_classes , ( num_examples , ) ) <EOL> Y = np . zeros ( ( num_examples , num_classes ) ) <EOL> for i in xrange ( num_examples ) : <EOL> Y [ i , idx [ i ] ] = <NUM_LIT:1> <EOL> return DenseDesignMatrix ( X = X , y = Y ) <EOL> def random_one_hot_topological_dense_design_matrix ( rng , <EOL> num_examples , <EOL> shape , <EOL> channels , <EOL> axes , <EOL> num_classes ) : <EOL> dims = { '<STR_LIT:b>' : num_examples , <EOL> '<STR_LIT:c>' : channels } <EOL> for i , dim in enumerate ( shape ) : <EOL> dims [ i ] = dim <EOL> shape = [ dims [ axis ] for axis in axes ] <EOL> X = rng . randn ( * shape ) <EOL> idx = rng . randint ( <NUM_LIT:0> , num_classes , ( num_examples , ) ) <EOL> Y = np . zeros ( ( num_examples , num_classes ) ) <EOL> for i in xrange ( num_examples ) : <EOL> Y [ i , idx [ i ] ] = <NUM_LIT:1> <EOL> return DenseDesignMatrix ( topo_view = X , axes = axes , y = Y ) <EOL> def random_dense_design_matrix_for_regression ( rng , num_examples , <EOL> dim , reg_min , reg_max ) : <EOL> """<STR_LIT>""" <EOL> X = rng . randn ( num_examples , dim ) <EOL> Y = rng . randint ( reg_min , reg_max , ( num_examples , <NUM_LIT:1> ) ) <EOL> return DenseDesignMatrix ( X = X , y = Y ) </s>
