Пример #1
0
class Relu(Function):
    Input('in_array', (chainer.Variable,))
    Output('out_array', (chainer.Variable,))

    def call(self):
        return self.ID + ' = relu('

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.relu
Пример #2
0
class HardSigmoid(Function):
    Input('in_array', (chainer.Variable,))
    Output('out_array', (chainer.Variable,))

    def call(self):
        return self.ID + ' = hard_sigmoid('

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.hard_sigmoid
Пример #3
0
class LeakyRelu(Function):
    Input('in_array', (chainer.Variable,))
    Input('slope', (float,))
    Output('out_array', (chainer.Variable,))

    def call(self):
        return self.ID + ' = leaky_relu(slope={0}, x='.format(self._slope)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.leaky_relu
Пример #4
0
class ClippedRelu(Function):
    Input('in_array', (chainer.Variable,))
    Input('z', (float,))
    Output('out_array', (chainer.Variable,))

    def call(self):
        self.check_member(('_alpha',))
        return self.ID + ' = clipped_relu(z={0}, x='.format(self._z)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.clipped_relu
Пример #5
0
class Dropout(Function):
    Input('in_array', (chainer.Variable,))
    Input('ratio', (float,))
    Output('out_array', (chainer.Variable,))

    def call(self):
        self.check_member(('_ratio',))
        return self.ID + ' = dropout(ratio={0}, x='.format(self._ratio)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.dropout
Пример #6
0
class VGG16(Link):
    Input('in_array', (chainer.Variable, ))
    Input('pretrained_model', (str, ))
    Output('out_array', (chainer.Variable, ))
    is_image_node = True

    def call_init(self):
        return 'VGG16Layers({pretrained_model}),' \
            .format(pretrained_model=self._pretrained_model)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.links.VGG16Layers
Пример #7
0
class AveragePooling2d(Function):
    Input('in_array', (chainer.Variable, ))
    Input('ksize', (int, ))
    Input('pad', (int, ))
    Output('out_array', (chainer.Variable, ))

    is_image_node = True

    def call(self):
        return self.ID + ' = average_pooling_2d(ksize={0}, pad={1}, x='.\
            format(self._ksize, self._pad)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.average_pooling_2d
Пример #8
0
class LocalResponseNormalization(Function):
    Input('in_array', (chainer.Variable, ))
    Input('n', (int, ))
    Input('k', (int, ))
    Input('alpha', (float, ))
    Input('beta', (float, ))
    Output('out_array', (chainer.Variable, ))
    is_image_node = True

    def call(self):
        return self.ID + ' = local_response_normalization(n={n}, k={k}, x=' \
            .format(n=self._n,
                    k=self._k)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.functions.LocalResponseNormalization
Пример #9
0
class BatchNormalization(Link):
    Input('in_array', (chainer.Variable, ))
    Input('size', (int, ))
    Input('decay', (float, ))
    Input('eps', (float, ))
    Input('use_gamma', (bool, ), select=[True, False])
    Input('use_beta', (bool, ), select=[True, False])
    Output('out_array', (chainer.Variable, ))
    is_image_node = True

    def call_init(self):
        return 'BatchNormalization({size}, {decay}, {eps}, numpy.float32, ' \
               '{use_gamma}, {use_beta}),' \
            .format(size=self._size,
                    decay=self._decay,
                    eps=self._eps,
                    use_gamma=self._use_gamma,
                    use_beta=self._use_beta)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.links.BatchNormalization
Пример #10
0
class Convolution2D(Link):
    Input('in_array', (chainer.Variable, ))
    Input('out_channels', (int, ))
    Input('ksize', (int, ))
    Input('stride', (int, ))
    Input('pad', (int, ))
    Input('nobias', (bool, ), select=[True, False])
    Output('out_array', (chainer.Variable, ))
    is_image_node = True

    def call_init(self):
        return 'Convolution2D({in_channels}, {out_channels}, {ksize}, ' \
               '{stride}, {pad}, {nobias}),' \
            .format(in_channels='None',
                    out_channels=self._out_channels,
                    ksize=self._ksize,
                    stride=self._stride,
                    pad=self._pad,
                    nobias=self._nobias)

    @classmethod
    def register_chainer_impl(cls):
        return chainer.links.Convolution2D