def build_model():
    input_size = data_sizes['sliced:data:singleslice']
    l0 = nn.layers.InputLayer(input_size)
    l1a = nn.layers.dnn.Conv2DDNNLayer(l0, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=64, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l1b = nn.layers.dnn.Conv2DDNNLayer(l1a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=64, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l1 = nn.layers.dnn.MaxPool2DDNNLayer(l1b, pool_size=(2, 2), stride=(2, 2))
    l2a = nn.layers.dnn.Conv2DDNNLayer(l1, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=128, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l2b = nn.layers.dnn.Conv2DDNNLayer(l2a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=128, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l2 = nn.layers.dnn.MaxPool2DDNNLayer(l2b, pool_size=(2, 2), stride=(2, 2))
    l3a = nn.layers.dnn.Conv2DDNNLayer(l2, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3b = nn.layers.dnn.Conv2DDNNLayer(l3a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3c = nn.layers.dnn.Conv2DDNNLayer(l3b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3 = nn.layers.dnn.MaxPool2DDNNLayer(l3c, pool_size=(2, 2), stride=(2, 2))
    l4a = nn.layers.dnn.Conv2DDNNLayer(l3, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4b = nn.layers.dnn.Conv2DDNNLayer(l4a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4c = nn.layers.dnn.Conv2DDNNLayer(l4b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4 = nn.layers.dnn.MaxPool2DDNNLayer(l4c, pool_size=(2, 2), stride=(2, 2))
    l5a = nn.layers.dnn.Conv2DDNNLayer(l4, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5b = nn.layers.dnn.Conv2DDNNLayer(l5a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5c = nn.layers.dnn.Conv2DDNNLayer(l5b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5 = nn.layers.dnn.MaxPool2DDNNLayer(l5c, pool_size=(2, 2), stride=(2, 2))
    ldsys1 = nn.layers.DenseLayer(l5, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    ldsys1drop = nn.layers.dropout(ldsys1, p=0.5)
    ldsys2 = nn.layers.DenseLayer(ldsys1drop, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    ldsys2drop = nn.layers.dropout(ldsys2, p=0.5)
    ldsys3 = nn.layers.DenseLayer(ldsys2drop, num_units=600, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.softmax)
    ldsys3drop = nn.layers.dropout(ldsys3, p=0.5)
    ldsys3dropnorm = layers.NormalisationLayer(ldsys3drop)
    l_systole = layers.CumSumLayer(ldsys3dropnorm)
    lddia1 = nn.layers.DenseLayer(l5, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    lddia1drop = nn.layers.dropout(lddia1, p=0.5)
    lddia2 = nn.layers.DenseLayer(lddia1drop, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    lddia2drop = nn.layers.dropout(lddia2, p=0.5)
    lddia3 = nn.layers.DenseLayer(lddia2drop, num_units=600, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.softmax)
    lddia3drop = nn.layers.dropout(lddia3, p=0.5)
    lddia3dropnorm = layers.NormalisationLayer(lddia3drop)
    l_diastole = layers.CumSumLayer(lddia3dropnorm)
    return {'inputs': {'sliced:data:singleslice': l0}, 'outputs': {'systole': l_systole, 'diastole': l_diastole}, 'regularizable': {ldsys1: l2_weight, ldsys2: l2_weight, ldsys3: l2_weight_out, lddia1: l2_weight, lddia2: l2_weight, lddia3: l2_weight_out}}
def build_model():
    input_size = data_sizes['sliced:data:singleslice']
    l0 = nn.layers.InputLayer(input_size)
    l1a = nn.layers.dnn.Conv2DDNNLayer(l0, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=64, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l1b = nn.layers.dnn.Conv2DDNNLayer(l1a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=64, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l1 = nn.layers.dnn.MaxPool2DDNNLayer(l1b, pool_size=(2, 2), stride=(2, 2))
    l2a = nn.layers.dnn.Conv2DDNNLayer(l1, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=128, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l2b = nn.layers.dnn.Conv2DDNNLayer(l2a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=128, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l2 = nn.layers.dnn.MaxPool2DDNNLayer(l2b, pool_size=(2, 2), stride=(2, 2))
    l3a = nn.layers.dnn.Conv2DDNNLayer(l2, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3b = nn.layers.dnn.Conv2DDNNLayer(l3a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3c = nn.layers.dnn.Conv2DDNNLayer(l3b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=256, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l3 = nn.layers.dnn.MaxPool2DDNNLayer(l3c, pool_size=(2, 2), stride=(2, 2))
    l4a = nn.layers.dnn.Conv2DDNNLayer(l3, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4b = nn.layers.dnn.Conv2DDNNLayer(l4a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4c = nn.layers.dnn.Conv2DDNNLayer(l4b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l4 = nn.layers.dnn.MaxPool2DDNNLayer(l4c, pool_size=(2, 2), stride=(2, 2))
    l5a = nn.layers.dnn.Conv2DDNNLayer(l4, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5b = nn.layers.dnn.Conv2DDNNLayer(l5a, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5c = nn.layers.dnn.Conv2DDNNLayer(l5b, W=nn.init.Orthogonal('relu'), filter_size=(3, 3), num_filters=512, stride=(1, 1), pad='same', nonlinearity=nn.nonlinearities.rectify)
    l5 = nn.layers.dnn.MaxPool2DDNNLayer(l5c, pool_size=(2, 2), stride=(2, 2))
    ldsys1 = nn.layers.DenseLayer(l5, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    ldsys1drop = nn.layers.dropout(ldsys1, p=0.5)
    ldsys2 = nn.layers.DenseLayer(ldsys1drop, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    ldsys2drop = nn.layers.dropout(ldsys2, p=0.5)
    ldsys3 = nn.layers.DenseLayer(ldsys2drop, num_units=600, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.softmax)
    ldsys3drop = nn.layers.dropout(ldsys3, p=0.5)
    ldsys3dropnorm = layers.NormalisationLayer(ldsys3drop)
    l_systole = layers.CumSumLayer(ldsys3dropnorm)
    lddia1 = nn.layers.DenseLayer(l5, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    lddia1drop = nn.layers.dropout(lddia1, p=0.5)
    lddia2 = nn.layers.DenseLayer(lddia1drop, num_units=512, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.rectify)
    lddia2drop = nn.layers.dropout(lddia2, p=0.5)
    lddia3 = nn.layers.DenseLayer(lddia2drop, num_units=600, W=nn.init.Orthogonal('relu'), b=nn.init.Constant(0.1), nonlinearity=nn.nonlinearities.softmax)
    lddia3drop = nn.layers.dropout(lddia3, p=0.5)
    lddia3dropnorm = layers.NormalisationLayer(lddia3drop)
    l_diastole = layers.CumSumLayer(lddia3dropnorm)
    return {'inputs': {'sliced:data:singleslice': l0}, 'outputs': {'systole': l_systole, 'diastole': l_diastole}, 'regularizable': {ldsys1: l2_weight, ldsys2: l2_weight, ldsys3: l2_weight_out, lddia1: l2_weight, lddia2: l2_weight, lddia3: l2_weight_out}}