<s> from jobman import DD , expand , flatten <EOL> import pynet . layer as layer <EOL> from pynet . model import * <EOL> from pynet . layer import * <EOL> from pynet . datasets . mnist import Mnist , Mnist_Blocks <EOL> import pynet . datasets . spec as spec <EOL> import pynet . datasets . mnist as mnist <EOL> import pynet . datasets . transfactor as tf <EOL> import pynet . datasets . mapping as mapping <EOL> import pynet . learning_method as learning_methods <EOL> from pynet . learning_rule import LearningRule <EOL> from pynet . log import Log <EOL> from pynet . train_object import TrainObject <EOL> from pynet . cost import Cost <EOL> import pynet . datasets . preprocessor as preproc <EOL> import pynet . datasets . dataset_noise as noisy <EOL> import pynet . layer_noise as layer_noise <EOL> import cPickle <EOL> import os <EOL> import theano <EOL> from theano . sandbox . cuda . var import CudaNdarraySharedVariable <EOL> floatX = theano . config . floatX <EOL> class AE : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def run ( self ) : <EOL> log = self . build_log ( ) <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> model = self . build_model ( dataset ) <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> def build_log ( self , save_to_database = None , id = None ) : <EOL> log = Log ( experiment_name = id is not None and '<STR_LIT>' % ( self . state . log . experiment_name , id ) or self . state . log . experiment_name , <EOL> description = self . state . log . description , <EOL> save_outputs = self . state . log . save_outputs , <EOL> save_learning_rule = self . state . log . save_learning_rule , <EOL> save_model = self . state . log . save_model , <EOL> save_epoch_error = self . state . log . save_epoch_error , <EOL> save_to_database = save_to_database ) <EOL> return log <EOL> def build_dataset ( self ) : <EOL> dataset = None <EOL> preprocessor = None if self . state . dataset . preprocessor . type is None else getattr ( preproc , self . state . dataset . preprocessor . type ) ( ) <EOL> noise = None if self . state . dataset . dataset_noise . type is None else getattr ( noisy , self . state . dataset . dataset_noise . type ) ( ) <EOL> if self . state . dataset . preprocessor . type == '<STR_LIT>' : <EOL> preprocessor . max = self . state . dataset . preprocessor . global_max <EOL> preprocessor . min = self . state . dataset . preprocessor . global_min <EOL> preprocessor . buffer = self . state . dataset . preprocessor . buffer <EOL> preprocessor . scale_range = self . state . dataset . preprocessor . scale_range <EOL> if self . state . dataset . type == '<STR_LIT>' : <EOL> dataset = Mnist ( train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> train = dataset . get_train ( ) <EOL> dataset . set_train ( train . X , train . X ) <EOL> valid = dataset . get_valid ( ) <EOL> dataset . set_valid ( valid . X , valid . X ) <EOL> test = dataset . get_test ( ) <EOL> dataset . set_test ( test . X , test . X ) <EOL> elif self . state . dataset . type [ : <NUM_LIT:12> ] == '<STR_LIT>' : <EOL> dataset = getattr ( mnist , self . state . dataset . type ) ( <EOL> feature_size = self . state . dataset . feature_size , <EOL> target_size = self . state . dataset . feature_size , <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> elif self . state . dataset . type [ : <NUM_LIT:4> ] == '<STR_LIT>' : <EOL> dataset = getattr ( spec , self . state . dataset . type ) ( <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> train = dataset . get_train ( ) <EOL> dataset . set_train ( train . X , train . X ) <EOL> valid = dataset . get_valid ( ) <EOL> dataset . set_valid ( valid . X , valid . X ) <EOL> test = dataset . get_test ( ) <EOL> dataset . set_test ( test . X , test . X ) <EOL> elif self . state . dataset . type [ : <NUM_LIT:5> ] == '<STR_LIT>' : <EOL> dataset = getattr ( spec , self . state . dataset . type ) ( <EOL> feature_size = self . state . dataset . feature_size , <EOL> target_size = self . state . dataset . feature_size , <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> elif self . state . dataset . type [ : <NUM_LIT> ] == '<STR_LIT>' : <EOL> dataset = getattr ( tf , self . state . dataset . type ) ( <EOL> feature_size = self . state . dataset . feature_size , <EOL> target_size = self . state . dataset . feature_size , <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> elif self . state . dataset . type [ : <NUM_LIT:11> ] == '<STR_LIT>' : <EOL> dataset = getattr ( tf , self . state . dataset . type ) ( <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> noise = noise , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> train = dataset . get_train ( ) <EOL> dataset . set_train ( train . X , train . X ) <EOL> valid = dataset . get_valid ( ) <EOL> dataset . set_valid ( valid . X , valid . X ) <EOL> test = dataset . get_test ( ) <EOL> dataset . set_test ( test . X , test . X ) <EOL> return dataset <EOL> def build_learning_method ( self ) : <EOL> if self . state . learning_method . type == '<STR_LIT>' : <EOL> learn_method = getattr ( learning_methods , <EOL> self . state . learning_method . type ) ( <EOL> learning_rate = self . state . learning_method . learning_rate , <EOL> momentum = self . state . learning_method . momentum ) <EOL> elif self . state . learning_method . type == '<STR_LIT>' : <EOL> learn_method = getattr ( learning_methods , <EOL> self . state . learning_method . type ) ( <EOL> learning_rate = self . state . learning_method . learning_rate , <EOL> momentum = self . state . learning_method . momentum ) <EOL> elif self . state . learning_method . type == '<STR_LIT>' : <EOL> learn_method = getattr ( learning_methods , <EOL> self . state . learning_method . type ) ( <EOL> rho = self . state . learning_method . rho , <EOL> eps = self . state . learning_method . eps ) <EOL> else : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> return learn_method <EOL> def build_learning_rule ( self ) : <EOL> learning_rule = LearningRule ( max_col_norm = self . state . learning_rule . max_col_norm , <EOL> L1_lambda = self . state . learning_rule . L1_lambda , <EOL> L2_lambda = self . state . learning_rule . L2_lambda , <EOL> training_cost = Cost ( type = self . state . learning_rule . cost ) , <EOL> stopping_criteria = { '<STR_LIT>' : self . state . learning_rule . stopping_criteria . max_epoch , <EOL> '<STR_LIT>' : self . state . learning_rule . stopping_criteria . epoch_look_back , <EOL> '<STR_LIT>' : Cost ( type = self . state . learning_rule . stopping_criteria . cost ) , <EOL> '<STR_LIT>' : self . state . learning_rule . stopping_criteria . percent_decrease } ) <EOL> return learning_rule <EOL> def build_one_hid_model ( self , input_dim ) : <EOL> model = AutoEncoder ( input_dim = input_dim , rand_seed = self . state . model . rand_seed ) <EOL> h1_noise = None if self . state . hidden1 . layer_noise . type is None else getattr ( layer_noise , self . state . hidden1 . layer_noise . type ) ( ) <EOL> if self . state . hidden1 . layer_noise . type in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> h1_noise . ratio = self . state . hidden1 . layer_noise . ratio <EOL> elif self . state . hidden1 . layer_noise . type == '<STR_LIT>' : <EOL> h1_noise . std = self . state . hidden1 . layer_noise . std <EOL> h1_noise . mean = self . state . hidden1 . layer_noise . mean <EOL> hidden1 = getattr ( layer , self . state . hidden1 . type ) ( dim = self . state . hidden1 . dim , <EOL> name = self . state . hidden1 . name , <EOL> dropout_below = self . state . hidden1 . dropout_below , <EOL> noise = h1_noise ) <EOL> model . add_encode_layer ( hidden1 ) <EOL> h1_mirror = getattr ( layer , self . state . h1_mirror . type ) ( dim = input_dim , <EOL> name = self . state . h1_mirror . name , <EOL> W = hidden1 . W . T , <EOL> dropout_below = self . state . h1_mirror . dropout_below ) <EOL> model . add_decode_layer ( h1_mirror ) <EOL> return model <EOL> def build_one_hid_model_no_transpose ( self , input_dim ) : <EOL> model = AutoEncoder ( input_dim = input_dim , rand_seed = self . state . model . rand_seed ) <EOL> hidden1 = getattr ( layer , self . state . hidden1 . type ) ( dim = self . state . hidden1 . dim , <EOL> name = self . state . hidden1 . name , <EOL> dropout_below = self . state . hidden1 . dropout_below , <EOL> noise = None if self . state . hidden1 . layer_noise is None else getattr ( layer_noise , self . state . hidden1 . layer_noise ) ( ) ) <EOL> model . add_encode_layer ( hidden1 ) <EOL> h1_mirror = getattr ( layer , self . state . h1_mirror . type ) ( dim = input_dim , <EOL> name = self . state . h1_mirror . name , <EOL> dropout_below = self . state . h1_mirror . dropout_below ) <EOL> model . add_decode_layer ( h1_mirror ) <EOL> return model <EOL> def build_two_hid_model ( self , input_dim ) : <EOL> model = AutoEncoder ( input_dim = input_dim , rand_seed = self . state . model . rand_seed ) <EOL> hidden1 = getattr ( layer , self . state . hidden1 . type ) ( dim = self . state . hidden1 . dim , <EOL> name = self . state . hidden1 . name , <EOL> dropout_below = self . state . hidden1 . dropout_below , <EOL> noise = None if self . state . hidden1 . layer_noise is None else getattr ( layer_noise , self . state . hidden1 . layer_noise ) ( ) ) <EOL> model . add_encode_layer ( hidden1 ) <EOL> hidden2 = getattr ( layer , self . state . hidden2 . type ) ( dim = self . state . hidden2 . dim , <EOL> name = self . state . hidden2 . name , <EOL> dropout_below = self . state . hidden2 . dropout_below , <EOL> noise = None if self . state . hidden2 . layer_noise is None else getattr ( layer_noise , self . state . hidden2 . layer_noise ) ( ) ) <EOL> model . add_encode_layer ( hidden2 ) <EOL> hidden2_mirror = getattr ( layer , self . state . h2_mirror . type ) ( dim = self . state . hidden1 . dim , <EOL> name = self . state . h2_mirror . name , <EOL> dropout_below = self . state . h2_mirror . dropout_below , <EOL> W = hidden2 . W . T ) <EOL> model . add_decode_layer ( hidden2_mirror ) <EOL> hidden1_mirror = getattr ( layer , self . state . h1_mirror . type ) ( dim = input_dim , <EOL> name = self . state . h1_mirror . name , <EOL> dropout_below = self . state . h1_mirror . dropout_below , <EOL> W = hidden1 . W . T ) <EOL> model . add_decode_layer ( hidden1_mirror ) <EOL> return model <EOL> def build_database ( self , dataset , learning_rule , learning_method , model ) : <EOL> save_to_database = { '<STR_LIT:name>' : self . state . log . save_to_database_name , <EOL> '<STR_LIT>' : { '<STR_LIT>' : dataset . __class__ . __name__ , <EOL> '<STR_LIT>' : learning_rule . max_col_norm , <EOL> '<STR_LIT>' : model . rand_seed , <EOL> '<STR_LIT>' : str ( [ layer . dropout_below for layer in model . layers ] ) , <EOL> '<STR_LIT>' : learning_method . __class__ . __name__ , <EOL> '<STR_LIT>' : dataset . batch_size , <EOL> '<STR_LIT>' : dataset . noise . __class__ . __name__ , <EOL> '<STR_LIT>' : dataset . data_dir , <EOL> '<STR_LIT>' : dataset . feature_size ( ) , <EOL> '<STR_LIT>' : dataset . nblocks ( ) , <EOL> '<STR_LIT>' : str ( [ layer . __class__ . __name__ for layer in model . layers ] ) , <EOL> '<STR_LIT>' : str ( [ layer . dim for layer in model . layers ] ) , <EOL> '<STR_LIT>' : dataset . preprocessor . __class__ . __name__ , <EOL> '<STR_LIT>' : learning_rule . cost . type , <EOL> '<STR_LIT>' : learning_rule . stopping_criteria [ '<STR_LIT>' ] . type } <EOL> } <EOL> if learning_method . __class__ . __name__ == "<STR_LIT>" : <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . learning_rate <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . momentum <EOL> elif learning_method . __class__ . __name__ == "<STR_LIT>" : <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . learning_rate <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . momentum <EOL> elif learning_method . __class__ . __name__ == "<STR_LIT>" : <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . rho <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = learning_method . eps <EOL> else : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> layer_noise = [ ] <EOL> layer_noise_params = [ ] <EOL> for layer in model . layers : <EOL> layer_noise . append ( layer . noise . __class__ . __name__ ) <EOL> if layer . noise . __class__ . __name__ in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> layer_noise_params . append ( layer . noise . ratio ) <EOL> elif layer . noise . __class__ . __name__ is '<STR_LIT>' : <EOL> layer_noise_params . append ( ( layer . noise . mean , layer . noise . std ) ) <EOL> else : <EOL> layer_noise_params . append ( None ) <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = str ( layer_noise ) <EOL> save_to_database [ "<STR_LIT>" ] [ "<STR_LIT>" ] = str ( layer_noise_params ) <EOL> return save_to_database <EOL> class AE_Testing ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> model = self . build_one_hid_model ( dataset . feature_size ( ) ) <EOL> if self . state . log . save_to_database_name : <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> log = self . build_log ( database ) <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> train_obj . model . layers [ <NUM_LIT:0> ] . dropout_below = None <EOL> train_obj . setup ( ) <EOL> train_obj . run ( ) <EOL> class Laura_Mapping ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def run ( self ) : <EOL> preprocessor = None if self . state . dataset . preprocessor is None else getattr ( preproc , self . state . dataset . preprocessor ) ( ) <EOL> dataset = getattr ( mapping , self . state . dataset . type ) ( feature_size = self . state . dataset . feature_size , <EOL> target_size = self . state . dataset . target_size , <EOL> train_valid_test_ratio = self . state . dataset . train_valid_test_ratio , <EOL> preprocessor = preprocessor , <EOL> batch_size = self . state . dataset . batch_size , <EOL> num_batches = self . state . dataset . num_batches , <EOL> iter_class = self . state . dataset . iter_class , <EOL> rng = self . state . dataset . rng ) <EOL> model = MLP ( input_dim = self . state . dataset . feature_size , rand_seed = self . state . model . rand_seed ) <EOL> hidden1 = getattr ( layer , self . state . hidden1 . type ) ( dim = self . state . hidden1 . dim , <EOL> name = self . state . hidden1 . name , <EOL> dropout_below = self . state . hidden1 . dropout_below ) <EOL> model . add_layer ( hidden1 ) <EOL> hidden2 = getattr ( layer , self . state . hidden2 . type ) ( dim = self . state . hidden2 . dim , <EOL> name = self . state . hidden2 . name , <EOL> dropout_below = self . state . hidden2 . dropout_below ) <EOL> model . add_layer ( hidden2 ) <EOL> output = getattr ( layer , self . state . output . type ) ( dim = self . state . output . dim , <EOL> name = self . state . output . name , <EOL> dropout_below = self . state . output . dropout_below ) <EOL> model . add_layer ( output ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> log = self . build_log ( database ) <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> class Laura ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> if self . state . num_layers == <NUM_LIT:1> : <EOL> model = self . build_one_hid_model ( dataset . feature_size ( ) ) <EOL> elif self . state . num_layers == <NUM_LIT:2> : <EOL> model = self . build_two_hid_model ( dataset . feature_size ( ) ) <EOL> else : <EOL> raise ValueError ( ) <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> log = self . build_log ( database ) <EOL> dataset . log = log <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> for layer in train_obj . model . layers : <EOL> layer . dropout_below = None <EOL> layer . noise = None <EOL> train_obj . setup ( ) <EOL> train_obj . run ( ) <EOL> class Laura_Continue ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def build_model ( self ) : <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden1 . model + '<STR_LIT>' ) as f1 : <EOL> model = cPickle . load ( f1 ) <EOL> return model <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> model = self . build_model ( ) <EOL> if self . state . fine_tuning_only : <EOL> for layer in model . layers : <EOL> layer . dropout_below = None <EOL> layer . noise = None <EOL> print "<STR_LIT>" <EOL> if self . state . log . save_to_database_name : <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden1 . model <EOL> log = self . build_log ( database ) <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> if not self . state . fine_tuning_only : <EOL> log . info ( "<STR_LIT>" ) <EOL> for layer in train_obj . model . layers : <EOL> layer . dropout_below = None <EOL> layer . noise = None <EOL> train_obj . setup ( ) <EOL> train_obj . run ( ) <EOL> class Laura_Two_Layers ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def build_model ( self , input_dim ) : <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden1 . model + '<STR_LIT>' ) as f1 : <EOL> model1 = cPickle . load ( f1 ) <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden2 . model + '<STR_LIT>' ) as f2 : <EOL> model2 = cPickle . load ( f2 ) <EOL> model = AutoEncoder ( input_dim = input_dim ) <EOL> while len ( model1 . encode_layers ) > <NUM_LIT:0> : <EOL> model . add_encode_layer ( model1 . pop_encode_layer ( ) ) <EOL> while len ( model2 . encode_layers ) > <NUM_LIT:0> : <EOL> model . add_encode_layer ( model2 . pop_encode_layer ( ) ) <EOL> while len ( model2 . decode_layers ) > <NUM_LIT:0> : <EOL> model . add_decode_layer ( model2 . pop_decode_layer ( ) ) <EOL> while len ( model1 . decode_layers ) > <NUM_LIT:0> : <EOL> model . add_decode_layer ( model1 . pop_decode_layer ( ) ) <EOL> return model <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> model = self . build_model ( dataset . feature_size ( ) ) <EOL> model . layers [ <NUM_LIT:0> ] . dropout_below = self . state . hidden1 . dropout_below <EOL> if self . state . log . save_to_database_name : <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden1 . model <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden2 . model <EOL> log = self . build_log ( database ) <EOL> log . info ( "<STR_LIT>" ) <EOL> for layer in model . layers : <EOL> layer . dropout_below = None <EOL> layer . noise = None <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> class Laura_Three_Layers ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def build_model ( self , input_dim ) : <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden1 . model + '<STR_LIT>' ) as f1 : <EOL> model1 = cPickle . load ( f1 ) <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden2 . model + '<STR_LIT>' ) as f2 : <EOL> model2 = cPickle . load ( f2 ) <EOL> with open ( os . environ [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> + self . state . hidden3 . model + '<STR_LIT>' ) as f3 : <EOL> model3 = cPickle . load ( f3 ) <EOL> model = AutoEncoder ( input_dim = input_dim ) <EOL> model . add_encode_layer ( model1 . pop_encode_layer ( ) ) <EOL> model . add_encode_layer ( model2 . pop_encode_layer ( ) ) <EOL> model . add_encode_layer ( model3 . pop_encode_layer ( ) ) <EOL> model . add_decode_layer ( model3 . pop_decode_layer ( ) ) <EOL> model . add_decode_layer ( model2 . pop_decode_layer ( ) ) <EOL> model . add_decode_layer ( model1 . pop_decode_layer ( ) ) <EOL> return model <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> model = self . build_model ( dataset . feature_size ( ) ) <EOL> model . layers [ <NUM_LIT:0> ] . dropout_below = self . state . hidden1 . dropout_below <EOL> model . layers [ <NUM_LIT:1> ] . dropout_below = self . state . hidden2 . dropout_below <EOL> model . layers [ <NUM_LIT:2> ] . dropout_below = self . state . hidden3 . dropout_below <EOL> if self . state . log . save_to_database_name : <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden1 . model <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden2 . model <EOL> database [ '<STR_LIT>' ] [ '<STR_LIT>' ] = self . state . hidden3 . model <EOL> log = self . build_log ( database ) <EOL> log . info ( "<STR_LIT>" ) <EOL> for layer in model . layers : <EOL> layer . dropout_below = None <EOL> layer . noise = None <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> class Laura_Two_Layers_No_Transpose ( AE ) : <EOL> def __init__ ( self , state ) : <EOL> self . state = state <EOL> def run ( self ) : <EOL> dataset = self . build_dataset ( ) <EOL> learning_rule = self . build_learning_rule ( ) <EOL> learn_method = self . build_learning_method ( ) <EOL> if self . state . num_layers == <NUM_LIT:1> : <EOL> model = self . build_one_hid_model_no_transpose ( dataset . feature_size ( ) ) <EOL> else : <EOL> raise ValueError ( ) <EOL> if self . state . log . save_to_database_name : <EOL> database = self . build_database ( dataset , learning_rule , learn_method , model ) <EOL> log = self . build_log ( database ) <EOL> train_obj = TrainObject ( log = log , <EOL> dataset = dataset , <EOL> learning_rule = learning_rule , <EOL> learning_method = learn_method , <EOL> model = model ) <EOL> train_obj . run ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> train_obj . model . layers [ <NUM_LIT:0> ] . dropout_below = None <EOL> train_obj . setup ( ) <EOL> train_obj . run ( ) </s>
