#NEWLINE# def train( ) : #NEWLINE# #INDENT# data = Mnist ( batch_size = 64 , train_valid_test_ratio = [ 5 , 1 , 1 ] ) #NEWLINE# data . set_train ( X = data . get_train ( ) . X , y = data . get_train ( ) . X ) #NEWLINE# data . set_valid ( X = data . get_valid ( ) . X , y = data . get_valid ( ) . X ) #NEWLINE# model = Sequential ( input_var = T . matrix ( ) , output_var = T . matrix ( ) ) #NEWLINE# model . add ( Gaussian ( ) ) #NEWLINE# encode_layer1 = Linear ( prev_dim = ( 28 * 28 ) , this_dim = 200 ) #NEWLINE# model . add ( encode_layer1 ) #NEWLINE# model . add ( RELU ( ) ) #NEWLINE# encode_layer2 = Linear ( prev_dim = 200 , this_dim = 50 ) #NEWLINE# model . add ( encode_layer2 ) #NEWLINE# model . add ( Tanh ( ) ) #NEWLINE# decode_layer1 = Linear ( prev_dim = 50 , this_dim = 200 , W = encode_layer2 . W . T ) #NEWLINE# model . add ( decode_layer2 ) #NEWLINE# model . add ( RELU ( ) ) #NEWLINE# decode_layer2 = Linear ( prev_dim = 200 , this_dim = ( 28 * 28 ) , W = encode_layer1 . W . T ) #NEWLINE# model . add ( decode_layer2 ) #NEWLINE# model . add ( Sigmoid ( ) ) #NEWLINE# learning_method = AdaGrad ( learning_rate = 0.01 , momentum = 0.9 , lr_decay_factor = 0.9 , decay_batch = 10000 ) #NEWLINE# train_object = TrainObject ( model = model , log = None , dataset = data , train_cost = entropy , valid_cost = entropy , learning_method = learning_method , stop_criteria = { #NEWLINE# #INDENT# 'max_epoch' : 10 , #NEWLINE# 'epoch_look_back' : 5 , #NEWLINE# 'percent_decrease' : 0.01 , #NEWLINE# #UNINDENT# } ) #NEWLINE# train_object . setup ( ) #NEWLINE# train_object . run ( )