<s> '''<STR_LIT>''' <EOL> from __future__ import print_function <EOL> from keras . models import Sequential <EOL> from keras . layers . core import Dense , Dropout , Layer , Activation <EOL> from keras . datasets import mnist <EOL> from keras import backend as K <EOL> from keras . utils import np_utils <EOL> class Antirectifier ( Layer ) : <EOL> '''<STR_LIT>''' <EOL> def get_output_shape_for ( self , input_shape ) : <EOL> shape = list ( input_shape ) <EOL> assert len ( shape ) == <NUM_LIT:2> <EOL> shape [ - <NUM_LIT:1> ] *= <NUM_LIT:2> <EOL> return tuple ( shape ) <EOL> def call ( self , x , mask = None ) : <EOL> x -= K . mean ( x , axis = <NUM_LIT:1> , keepdims = True ) <EOL> x = K . l2_normalize ( x , axis = <NUM_LIT:1> ) <EOL> pos = K . relu ( x ) <EOL> neg = K . relu ( - x ) <EOL> return K . concatenate ( [ pos , neg ] , axis = <NUM_LIT:1> ) <EOL> batch_size = <NUM_LIT> <EOL> nb_classes = <NUM_LIT:10> <EOL> nb_epoch = <NUM_LIT> <EOL> ( X_train , y_train ) , ( X_test , y_test ) = mnist . load_data ( ) <EOL> X_train = X_train . reshape ( <NUM_LIT> , <NUM_LIT> ) <EOL> X_test = X_test . reshape ( <NUM_LIT> , <NUM_LIT> ) <EOL> X_train = X_train . astype ( '<STR_LIT>' ) <EOL> X_test = X_test . astype ( '<STR_LIT>' ) <EOL> X_train /= <NUM_LIT:255> <EOL> X_test /= <NUM_LIT:255> <EOL> print ( X_train . shape [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> print ( X_test . shape [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> Y_train = np_utils . to_categorical ( y_train , nb_classes ) <EOL> Y_test = np_utils . to_categorical ( y_test , nb_classes ) <EOL> model = Sequential ( ) <EOL> model . add ( Dense ( <NUM_LIT> , input_shape = ( <NUM_LIT> , ) ) ) <EOL> model . add ( Antirectifier ( ) ) <EOL> model . add ( Dropout ( <NUM_LIT:0.1> ) ) <EOL> model . add ( Dense ( <NUM_LIT> ) ) <EOL> model . add ( Antirectifier ( ) ) <EOL> model . add ( Dropout ( <NUM_LIT:0.1> ) ) <EOL> model . add ( Dense ( <NUM_LIT:10> ) ) <EOL> model . add ( Activation ( '<STR_LIT>' ) ) <EOL> model . compile ( loss = '<STR_LIT>' , <EOL> optimizer = '<STR_LIT>' , <EOL> metrics = [ '<STR_LIT>' ] ) <EOL> model . fit ( X_train , Y_train , <EOL> batch_size = batch_size , nb_epoch = nb_epoch , <EOL> verbose = <NUM_LIT:1> , validation_data = ( X_test , Y_test ) ) </s>
