Combine.compute_tensor()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
from . import NeuralLayer
2
3
4
class Combine(NeuralLayer):
5
    """
6
    Combine two variables.
7
    """
8
9
    def __init__(self, func, dim=0):
10
        """
11
        :type layer1: NeuralLayer
12
        :type layer2: NeuralLayer
13
        """
14
        super(Combine, self).__init__("combine")
15
        self.func = func
16
        if dim > 0:
17
            self.output_dim = dim
18
19
    def prepare(self):
20
        if self.output_dim == 0:
21
            self.output_dim = self.input_dim
22
23
    def compute_tensor(self, *tensors):
24
        return self.func(*tensors)
25
26
    def compute_tensor(self, *tensors):
27
        return self.func(*tensors)
28