Completed
Push — master ( c8682f...5bbe2a )
by Raphael
01:33
created

deepy.networks.BasicNetwork   A

Complexity

Total Complexity 10

Size/Duplication

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
C __init__() 0 22 8
A cost() 0 3 1
A test_cost() 0 3 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from . import NeuralNetwork
5
6
7
class BasicNetwork(NeuralNetwork):
8
    """
9
    A simple neural network that the last layer outputs cost.
10
    """
11
12
    def __init__(self, input_dim=0, model=None, config=None, input_tensor=None,
13
                 cost=None, blocks=None, input_vars=None, target_vars=None):
14
        """
15
        Create a basic network.
16
17
        Parameters:
18
            input_dim - dimension of input variable
19
            model - a short hand to specify the model
20
            config - network configuration
21
            input_tensor - specify the tensor of input if it's special
22
        """
23
        super(BasicNetwork, self).__init__(input_dim, config=config, input_tensor=input_tensor)
24
        if model:
25
            self.stack(model)
26
        if cost:
27
            self.stack(cost)
28
        if blocks:
29
            self.register(*blocks)
30
        if input_vars:
31
            self.input_variables = [t.tensor for t in input_vars]
32
        if target_vars:
33
            self.target_variables = [t.tensor for t in target_vars]
34
35
36
    @property
37
    def cost(self):
38
        return self.output
39
40
    @property
41
    def test_cost(self):
42
        return self.test_output