Completed
Push — master ( f73e69...91b7c0 )
by Raphael
01:35
created

deepy.layers.Combine   A

Complexity

Total Complexity 6

Size/Duplication

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Combine.compute_test_tesnor() 0 2 1
A Combine.compute_tensor() 0 2 1
A Combine.__init__() 0 9 2
A Combine.prepare() 0 3 2
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_test_tesnor(self, *tensors):
27
        return self.func(*tensors)
28