<s> 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> patch_sizes = [ ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> augmentation_params = { <EOL> '<STR_LIT>' : ( <NUM_LIT:1> / <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( - <NUM_LIT:20> , <NUM_LIT:20> ) , <EOL> '<STR_LIT>' : ( - <NUM_LIT:10> , <NUM_LIT:10> ) , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> batch_size = <NUM_LIT> // <NUM_LIT:4> <EOL> chunk_size = <NUM_LIT> // <NUM_LIT:4> <EOL> num_chunks_train = <NUM_LIT> <EOL> momentum = <NUM_LIT> <EOL> learning_rate_schedule = { <EOL> <NUM_LIT:0> : <NUM_LIT> , <EOL> <NUM_LIT> : <NUM_LIT> , <EOL> <NUM_LIT> : <NUM_LIT> , <EOL> } <EOL> validate_every = <NUM_LIT:20> <EOL> save_every = <NUM_LIT:20> <EOL> def estimate_scale ( img ) : <EOL> return np . maximum ( img . shape [ <NUM_LIT:0> ] , img . shape [ <NUM_LIT:1> ] ) / <NUM_LIT> <EOL> scale_factors = [ estimate_scale , <NUM_LIT> ] <EOL> augmentation_transforms_test = tta . build_quasirandom_transforms ( <NUM_LIT> , ** { <EOL> '<STR_LIT>' : ( <NUM_LIT:1> / <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( - <NUM_LIT:10> , <NUM_LIT:10> ) , <EOL> '<STR_LIT>' : ( - <NUM_LIT:8> , <NUM_LIT:8> ) , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } ) <EOL> data_loader = load . ZmuvMultiscaleDataLoader ( scale_factors = scale_factors , num_chunks_train = num_chunks_train , <EOL> patch_sizes = patch_sizes , chunk_size = chunk_size , augmentation_params = augmentation_params , <EOL> augmentation_transforms_test = augmentation_transforms_test ) <EOL> Conv2DLayer = tmp_dnn . Conv2DDNNLayer <EOL> MaxPool2DLayer = tmp_dnn . MaxPool2DDNNLayer <EOL> def build_model ( ) : <EOL> l0_variable = nn . layers . InputLayer ( ( batch_size , <NUM_LIT:1> , patch_sizes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , patch_sizes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) ) <EOL> l0c = dihedral . CyclicSliceLayer ( l0_variable ) <EOL> l1a = Conv2DLayer ( l0c , num_filters = <NUM_LIT:32> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l1b = Conv2DLayer ( l1a , num_filters = <NUM_LIT:32> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l1 = MaxPool2DLayer ( l1b , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l2a = Conv2DLayer ( l1 , num_filters = <NUM_LIT:64> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l2b = Conv2DLayer ( l2a , num_filters = <NUM_LIT:64> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l2 = MaxPool2DLayer ( l2b , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l3a = Conv2DLayer ( l2 , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3b = Conv2DLayer ( l3a , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3c = Conv2DLayer ( l3b , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3 = MaxPool2DLayer ( l3c , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l4a = Conv2DLayer ( l3 , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l4b = Conv2DLayer ( l4a , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l4c = Conv2DLayer ( l4b , num_filters = <NUM_LIT> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l4 = MaxPool2DLayer ( l4c , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l4f = nn . layers . flatten ( l4 ) <EOL> l5 = nn . layers . DenseLayer ( nn . layers . dropout ( l4f , p = <NUM_LIT:0.5> ) , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l5r = dihedral . CyclicRollLayer ( l5 ) <EOL> l6 = nn . layers . DenseLayer ( nn . layers . dropout ( l5r , p = <NUM_LIT:0.5> ) , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l_variable = dihedral . CyclicPoolLayer ( l6 , pool_function = nn_plankton . rms ) <EOL> l0_fixed = nn . layers . InputLayer ( ( batch_size , <NUM_LIT:1> , patch_sizes [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , patch_sizes [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> l0c = dihedral . CyclicSliceLayer ( l0_fixed ) <EOL> l1a = Conv2DLayer ( l0c , num_filters = <NUM_LIT:16> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l1b = Conv2DLayer ( l1a , num_filters = <NUM_LIT:16> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l1 = MaxPool2DLayer ( l1b , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l2a = Conv2DLayer ( l1 , num_filters = <NUM_LIT:32> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l2b = Conv2DLayer ( l2a , num_filters = <NUM_LIT:32> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l2 = MaxPool2DLayer ( l2b , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l3a = Conv2DLayer ( l2 , num_filters = <NUM_LIT:64> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3b = Conv2DLayer ( l3a , num_filters = <NUM_LIT:64> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3c = Conv2DLayer ( l3b , num_filters = <NUM_LIT:64> , filter_size = ( <NUM_LIT:3> , <NUM_LIT:3> ) , border_mode = "<STR_LIT>" , W = nn_plankton . Conv2DOrthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l3 = MaxPool2DLayer ( l3c , ds = ( <NUM_LIT:3> , <NUM_LIT:3> ) , strides = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> l3f = nn . layers . flatten ( l3 ) <EOL> l4 = nn . layers . DenseLayer ( nn . layers . dropout ( l3f , p = <NUM_LIT:0.5> ) , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l4r = dihedral . CyclicRollLayer ( l4 ) <EOL> l5 = nn . layers . DenseLayer ( nn . layers . dropout ( l4r , p = <NUM_LIT:0.5> ) , num_units = <NUM_LIT> , W = nn_plankton . Orthogonal ( <NUM_LIT:1.0> ) , b = nn . init . Constant ( <NUM_LIT:0.1> ) ) <EOL> l_fixed = dihedral . CyclicPoolLayer ( l5 , pool_function = nn_plankton . rms ) <EOL> l_merged = nn . layers . concat ( [ l_variable , l_fixed ] ) <EOL> l7 = nn . layers . DenseLayer ( nn . layers . dropout ( l_merged , p = <NUM_LIT:0.5> ) , num_units = data . num_classes , nonlinearity = T . nnet . softmax , W = nn_plankton . Orthogonal ( <NUM_LIT:1.0> ) ) <EOL> return [ l0_variable , l0_fixed ] , l7 </s>
