<s> import numpy as np <EOL> from passage . models import RNN <EOL> from passage . updates import NAG , Regularizer <EOL> from passage . layers import Generic , GatedRecurrent , Dense <EOL> from passage . utils import load , save <EOL> from load import load_mnist <EOL> trX , teX , trY , teY = load_mnist ( ) <EOL> layers = [ <EOL> Generic ( size = <NUM_LIT> ) , <EOL> GatedRecurrent ( size = <NUM_LIT> , p_drop = <NUM_LIT> ) , <EOL> Dense ( size = <NUM_LIT:10> , activation = '<STR_LIT>' , p_drop = <NUM_LIT:0.5> ) <EOL> ] <EOL> updater = NAG ( momentum = <NUM_LIT> , regularizer = Regularizer ( l2 = <NUM_LIT> ) ) <EOL> model = RNN ( layers = layers , updater = updater , iterator = '<STR_LIT>' , cost = '<STR_LIT>' ) <EOL> model . fit ( trX , trY , n_epochs = <NUM_LIT:20> ) <EOL> tr_preds = model . predict ( trX [ : len ( teY ) ] ) <EOL> te_preds = model . predict ( teX ) <EOL> tr_acc = np . mean ( trY [ : len ( teY ) ] == np . argmax ( tr_preds , axis = <NUM_LIT:1> ) ) <EOL> te_acc = np . mean ( teY == np . argmax ( te_preds , axis = <NUM_LIT:1> ) ) <EOL> print '<STR_LIT>' , tr_acc , '<STR_LIT>' , te_acc </s>
