Completed
Push — master ( c8682f...5bbe2a )
by Raphael
01:33
created

deepy.layers.Block.output()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 2
rs 10
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from layer import NeuralLayer
5
6
7
class Block(NeuralLayer):
8
    """
9
    Create a block, which contains the parameters of many connected layers.
10
    """
11
12
    def __init__(self):
13
        super(Block, self).__init__("block")
14
        self.layers = []
15
16
    def register(self, *layers):
17
        """
18
        Register many connected layers.
19
        :type layers: list of NeuralLayer
20
        """
21
        for layer in layers:
22
            self.register_layer(layer)
23
24
    def register_layer(self, layer):
25
        """
26
        Register one connected layer.
27
        :type layer: NeuralLayer
28
        """
29
        if not layer.connected:
30
            raise SystemError("%s is not connected, call `compute` before register it" % str(layer))
31
        self.layers.append(layer)
32
        self.register_inner_layers(layer)
33
34
    def output(self, x):
35
        return x
36
37
    def test_output(self, x):
38
        return x