<commit_before># file model.py
# allows the definition of different models to be trained
# for initialization: Lasagne/lasagne/init.py
# for nonlinearities: Lasagne/lasagne/nonlinearities.py
# for layers: Lasagne/lasagne/layers/

from lasagne import layers
from lasagne.layers import cuda_convnet
from lasagne import nonlinearities
from lasagne import init

# use cuda_convnet for a speed improvement
# will not be available without a GPU
Conv2DLayer = cuda_convnet.Conv2DCCLayer
MaxPool2DLayer = cuda_convnet.MaxPool2DCCLayer


def build_model(batch_size, input_width, input_height, input_channels, output_dims):
    l_in = layers.InputLayer(
        # variable batch size (None), channel, width, height
        shape=(None, input_channels, input_width, input_height)
    )

    l_noise = layers.GaussianNoiseLayer(
        l_in,
    )

    l_conv1 = Conv2DLayer(
        l_noise,
        num_filters=32,
        filter_size=(5, 5),
        # nonlinearity=nonlinearities.rectify,
        nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool1 = MaxPool2DLayer(
        l_conv1,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_conv2 = Conv2DLayer(
        l_pool1,
        num_filters=64,
        filter_size=(3, 3),
        # nonlinearity=nonlinearities.rectify,
        nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool2 = MaxPool2DLayer(
        l_conv2,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_conv3 = Conv2DLayer(
        l_pool2,
        num_filters=128,
        filter_size=(3, 3),
        # nonlinearity=nonlinearities.rectify,
        nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool3 = MaxPool2DLayer(
        l_conv3,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_hidden1 = layers.DenseLayer(
        l_pool3,
        num_units=1024,
        # nonlinearity=nonlinearities.rectify,
        nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_hidden1_maxout = layers.FeaturePoolLayer(
        l_hidden1,
        ds=2,
    )

    l_hidden1_dropout = layers.DropoutLayer(l_hidden1_maxout, p=0.5)

    l_hidden2 = layers.DenseLayer(
        l_hidden1_dropout,
        num_units=1024,
        # nonlinearity=nonlinearities.rectify,
        nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_hidden2_maxout = layers.FeaturePoolLayer(
        l_hidden2,
        ds=2,
    )

    l_hidden2_dropout = layers.DropoutLayer(l_hidden2_maxout, p=0.5)<commit_msg>Updates for better regularization<commit_after># file model.py
# allows the definition of different models to be trained
# for initialization: Lasagne/lasagne/init.py
# for nonlinearities: Lasagne/lasagne/nonlinearities.py
# for layers: Lasagne/lasagne/layers/

from lasagne import layers
from lasagne.layers import cuda_convnet
from lasagne import nonlinearities
from lasagne import init

# use cuda_convnet for a speed improvement
# will not be available without a GPU
Conv2DLayer = cuda_convnet.Conv2DCCLayer
MaxPool2DLayer = cuda_convnet.MaxPool2DCCLayer


def build_model(batch_size, input_width, input_height, input_channels, output_dims):
    l_in = layers.InputLayer(
        # variable batch size (None), channel, width, height
        shape=(None, input_channels, input_width, input_height)
    )

    l_noise = layers.GaussianNoiseLayer(
        l_in,
    )

    l_conv1 = Conv2DLayer(
        l_noise,
        num_filters=32,
        filter_size=(5, 5),
        nonlinearity=nonlinearities.rectify,
        # nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool1 = MaxPool2DLayer(
        l_conv1,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_conv2 = Conv2DLayer(
        l_pool1,
        num_filters=64,
        filter_size=(3, 3),
        nonlinearity=nonlinearities.rectify,
        # nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool2 = MaxPool2DLayer(
        l_conv2,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_conv3 = Conv2DLayer(
        l_pool2,
        num_filters=128,
        filter_size=(3, 3),
        nonlinearity=nonlinearities.rectify,
        # nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_pool3 = MaxPool2DLayer(
        l_conv3,
        ds=(2, 2),
        strides=(2, 2),
    )

    l_hidden1 = layers.DenseLayer(
        l_pool3,
        num_units=1024,
        nonlinearity=nonlinearities.rectify,
        # nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_hidden1_maxout = layers.FeaturePoolLayer(
        l_hidden1,
        ds=2,
    )

    l_hidden1_dropout = layers.DropoutLayer(l_hidden1_maxout, p=0.5)

    l_hidden2 = layers.DenseLayer(
        l_hidden1_dropout,
        num_units=1024,
        nonlinearity=nonlinearities.rectify,
        # nonlinearity=nonlinearities.LeakyRectify,
        W=init.GlorotUniform(),
    )

    l_hidden2_maxout = layers.FeaturePoolLayer(
        l_hidden2,
        ds=2,
    )

    l_hidden2_dropout = layers.DropoutLayer(l_hidden2_maxout, p=0.5)
{'fraction_non_alphanumeric': 0.08975346687211094, 'fraction_numerical': 0.02773497688751926, 'mean_word_length': 2.688210227272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1011362', 'n_tokens_mistral': 1850, 'n_tokens_neox': 1757, 'n_words': 306}