<commit_before>import chainer
from chainer import functions as F
from chainer import links as L

from wn_convolution_2d import WNConvolution2D
from wn_linear import WNLinear
import crelu


class NatureDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=512,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 32, 8, stride=4, bias=bias),
            L.Convolution2D(32, 64, 4, stride=2, bias=bias),
            L.Convolution2D(64, 64, 3, stride=1, bias=bias),
            L.Linear(3136, n_output_channels, bias=bias),
        ]

        super(NatureDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h


class NIPSDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 16, 8, stride=4, bias=bias),
            L.Convolution2D(16, 32, 4, stride=2, bias=bias),
            L.Linear(2592, n_output_channels, bias=bias),
        ]

        super(NIPSDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h


class NatureDQNHeadCReLU(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=512,
                 activation=F.relu):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 32 / 2, 8, stride=4),
            L.Convolution2D(32, 64 / 2, 4, stride=2),
            L.Convolution2D(64, 64 / 2, 3, stride=1),
            L.Linear(3136, n_output_channels / 2),
        ]

        super(NatureDQNHeadCReLU, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h


class NIPSDQNHeadCReLU(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256):
        self.n_input_channels = n_input_channels
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 16 / 2, 8, stride=4),
            L.Convolution2D(16, 32 / 2, 4, stride=2),
            L.Linear(2592, n_output_channels / 2),
        ]

        super(NIPSDQNHeadCReLU, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = crelu.crelu(layer(h))
        return h


class WNNIPSDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            WNConvolution2D(n_input_channels, 16, 8, stride=4, bias=bias),
            WNConvolution2D(16, 32, 4, stride=2, bias=bias),
            WNLinear(2592, n_output_channels, bias=bias),
        ]

        super(WNNIPSDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h
<commit_msg>Use crelu<commit_after>import chainer
from chainer import functions as F
from chainer import links as L

from wn_convolution_2d import WNConvolution2D
from wn_linear import WNLinear
import crelu


class NatureDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=512,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 32, 8, stride=4, bias=bias),
            L.Convolution2D(32, 64, 4, stride=2, bias=bias),
            L.Convolution2D(64, 64, 3, stride=1, bias=bias),
            L.Linear(3136, n_output_channels, bias=bias),
        ]

        super(NatureDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h


class NIPSDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 16, 8, stride=4, bias=bias),
            L.Convolution2D(16, 32, 4, stride=2, bias=bias),
            L.Linear(2592, n_output_channels, bias=bias),
        ]

        super(NIPSDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h


class NatureDQNHeadCReLU(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=512):
        self.n_input_channels = n_input_channels
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 32 / 2, 8, stride=4),
            L.Convolution2D(32, 64 / 2, 4, stride=2),
            L.Convolution2D(64, 64 / 2, 3, stride=1),
            L.Linear(3136, n_output_channels / 2),
        ]

        super(NatureDQNHeadCReLU, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = crelu.crelu(layer(h))
        return h


class NIPSDQNHeadCReLU(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256):
        self.n_input_channels = n_input_channels
        self.n_output_channels = n_output_channels

        layers = [
            L.Convolution2D(n_input_channels, 16 / 2, 8, stride=4),
            L.Convolution2D(16, 32 / 2, 4, stride=2),
            L.Linear(2592, n_output_channels / 2),
        ]

        super(NIPSDQNHeadCReLU, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = crelu.crelu(layer(h))
        return h


class WNNIPSDQNHead(chainer.ChainList):

    def __init__(self, n_input_channels=4, n_output_channels=256,
                 activation=F.relu, bias=0.1):
        self.n_input_channels = n_input_channels
        self.activation = activation
        self.n_output_channels = n_output_channels

        layers = [
            WNConvolution2D(n_input_channels, 16, 8, stride=4, bias=bias),
            WNConvolution2D(16, 32, 4, stride=2, bias=bias),
            WNLinear(2592, n_output_channels, bias=bias),
        ]

        super(WNNIPSDQNHead, self).__init__(*layers)

    def __call__(self, state):
        h = chainer.Variable(state)
        for layer in self:
            h = self.activation(layer(h))
        return h

{'fraction_non_alphanumeric': 0.09929736179239029, 'fraction_numerical': 0.03420389765345353, 'mean_word_length': 2.4526315789473685, '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': '1939436', 'n_tokens_mistral': 2677, 'n_tokens_neox': 2446, 'n_words': 486}