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

deepy.layers.Concatenate   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %
Metric Value
dl 0
loc 24
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_output() 0 2 1
A output() 0 2 1
A prepare() 0 2 1
A __init__() 0 9 2
1
import theano.tensor as T
2
from . import NeuralLayer
3
4
5
class Concatenate(NeuralLayer):
6
    """
7
    Concatenate two tensors.
8
    They should have identical dimensions except the last one.
9
    """
10
11
    def __init__(self, axis=2):
12
        """
13
        :type layer1: NeuralLayer
14
        :type layer2: NeuralLayer
15
        """
16
        super(Concatenate, self).__init__("concate")
17
        self.axis = axis
18
        if axis < 0:
19
            raise Exception("There are some bugs in T.concatenate, that axis can not lower than 0")
20
21
    def prepare(self):
22
        self.output_dim = sum(self.input_dims)
23
24
    def output(self, *xs):
25
        return T.concatenate(xs, axis=self.axis)
26
27
    def test_output(self, *xs):
28
        return T.concatenate(xs, axis=self.axis)
29