Bias   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 16
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepare() 0 4 1
A __init__() 0 2 1
A compute_tensor() 0 2 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from . import NeuralLayer
5
6
class Bias(NeuralLayer):
7
    """
8
    Bias layer.
9
    """
10
11
    def __init__(self):
12
        super(Bias, self).__init__("bias")
13
14
15
    def prepare(self):
16
        self.output_dim = self.input_dim
17
        self.B = self.create_bias(self.output_dim, "bias")
18
        self.register_parameters(self.B)
19
20
    def compute_tensor(self, x):
21
        return x + self.B