Concatenate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
dl 0
loc 23
rs 10
c 6
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 7 1
A prepare() 0 2 1
A compute_tensor() 0 6 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=-1):
12
        """
13
        :type layer1: NeuralLayer
14
        :type layer2: NeuralLayer
15
        """
16
        super(Concatenate, self).__init__("concate")
17
        self.axis = axis
18
19
    def prepare(self):
20
        self.output_dim = sum(self.input_dims)
21
22
    def compute_tensor(self, *xs):
23
        if self.axis == -1:
24
            axis = xs[0].ndim - 1
25
        else:
26
            axis = self.axis
27
        return T.concatenate(xs, axis=axis)