<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import theano <EOL> import theano . tensor as T <EOL> import lasagne as nn <EOL> import data <EOL> import load <EOL> import nn_plankton <EOL> import dihedral <EOL> import tmp_dnn <EOL> import tta <EOL> batch_size = <NUM_LIT> <EOL> chunk_size = <NUM_LIT> <EOL> num_chunks_train = <NUM_LIT> <EOL> momentum = <NUM_LIT> <EOL> learning_rate_schedule = { <EOL> <NUM_LIT:0> : <NUM_LIT> , <EOL> <NUM_LIT:100> : <NUM_LIT> , <EOL> <NUM_LIT:200> : <NUM_LIT> , <EOL> } <EOL> validate_every = <NUM_LIT> <EOL> save_every = <NUM_LIT> <EOL> sdir = "<STR_LIT>" <EOL> train_pred_file = "<STR_LIT>" <EOL> valid_pred_file = "<STR_LIT>" <EOL> test_pred_file = sdir + "<STR_LIT>" <EOL> data_loader = load . PredictionsWithMomentsDataLoader ( train_pred_file = train_pred_file , valid_pred_file = valid_pred_file , test_pred_file = test_pred_file , <EOL> num_chunks_train = num_chunks_train , chunk_size = chunk_size ) <EOL> create_train_gen = lambda : data_loader . create_random_gen ( ) <EOL> create_eval_train_gen = lambda : data_loader . create_fixed_gen ( "<STR_LIT:train>" ) <EOL> create_eval_valid_gen = lambda : data_loader . create_fixed_gen ( "<STR_LIT>" ) <EOL> create_eval_test_gen = lambda : data_loader . create_fixed_gen ( "<STR_LIT:test>" ) <EOL> def build_model ( ) : <EOL> l0 = nn . layers . InputLayer ( ( batch_size , data . num_classes ) ) <EOL> l0_size = nn . layers . InputLayer ( ( batch_size , <NUM_LIT:7> ) ) <EOL> l1_size = nn . layers . DenseLayer ( l0_size , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( '<STR_LIT:relu>' ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l2_size = nn . layers . DenseLayer ( l1_size , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( '<STR_LIT:relu>' ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3_size = nn . layers . DenseLayer ( l2_size , num_units = data . num_classes , W = nn_plankton . Orthogonal ( ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) , nonlinearity = None ) <EOL> l1 = nn_plankton . NonlinLayer ( l0 , T . log ) <EOL> ltot = nn . layers . ElemwiseSumLayer ( [ l1 , l3_size ] ) <EOL> lout = nn_plankton . NonlinLayer ( ltot , nonlinearity = T . nnet . softmax ) <EOL> return [ l0 , l0_size ] , lout <EOL> def build_objective ( l_ins , l_out ) : <EOL> print "<STR_LIT>" <EOL> lambda_reg = <NUM_LIT> <EOL> params = nn . layers . get_all_non_bias_params ( l_out ) <EOL> reg_term = sum ( T . sum ( p ** <NUM_LIT:2> ) for p in params ) <EOL> def loss ( y , t ) : <EOL> return nn_plankton . log_loss ( y , t ) + lambda_reg * reg_term <EOL> return nn . objectives . Objective ( l_out , loss_function = loss ) </s>
