# Path: utils/layer_macros.py
# def conv2dbn(l, name, **kwargs):
#     """ Batch normalized DNN Conv2D Layer """
#     l = nn.layers.dnn.Conv2DDNNLayer(
#         l, name=name,
#         **kwargs
#     )
#     l = batch_norm(l, name='%sbn' % name)
#     return l


import lasagne as nn
import theano.tensor as T
from utils.layer_macros import conv2dbn


def avg_pool(input_layer, **kwargs):
    # hack to work around https://github.com/Theano/Theano/issues/3776
    norm = nn.layers.ExpressionLayer(input_layer, lambda X: T.ones_like(X))
    norm = nn.layers.Pool2DLayer(norm, mode='average_inc_pad', **kwargs)
    l = nn.layers.Pool2DLayer(input_layer, mode='average_inc_pad', **kwargs)
    l = nn.layers.ElemwiseMergeLayer([l, norm], T.true_div)
    return l


def inceptionA(input_layer, name, nfilt):

# Path: utils/layer_macros.py
# def conv2dbn(l, name, **kwargs):
#     """ Batch normalized DNN Conv2D Layer """
#     l = nn.layers.dnn.Conv2DDNNLayer(
#         l, name=name,
#         **kwargs
#     )
#     l = batch_norm(l, name='%sbn' % name)
#     return l


# Path: utils/inception.py
import lasagne as nn
import theano.tensor as T
from utils.layer_macros import conv2dbn



def avg_pool(input_layer, **kwargs):
    # hack to work around https://github.com/Theano/Theano/issues/3776
    norm = nn.layers.ExpressionLayer(input_layer, lambda X: T.ones_like(X))
    norm = nn.layers.Pool2DLayer(norm, mode='average_inc_pad', **kwargs)
    l = nn.layers.Pool2DLayer(input_layer, mode='average_inc_pad', **kwargs)
    l = nn.layers.ElemwiseMergeLayer([l, norm], T.true_div)
    return l


def inceptionA(input_layer, name, nfilt):

    l1 = conv2dbn(