Combine   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 9 2
A prepare() 0 3 2
A compute_tensor() 0 2 1
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