Layer.py 1.04 KB
Newer Older
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
1 2 3 4 5
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Wed 11 May 2016 17:38 CEST

6
import tensorflow as tf
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
7 8 9 10 11 12 13 14


class Layer(object):

    """
    Layer base class
    """

15
    def __init__(self, name, activation=None, initialization='xavier', use_gpu=False, seed=10):
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
16 17 18 19 20 21 22
        """
        Base constructor

        **Parameters**
        input: Layer input

        """
23
        self.name = name
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
24 25 26 27
        self.initialization = initialization
        self.use_gpu = use_gpu
        self.seed = seed

28 29 30 31 32 33 34
        self.input = None
        self.activation = None
        self.output = None

    def create_variables(self, input):
        NotImplementedError("Please implement this function in derived classes")

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
35 36
    def get_graph(self):
        NotImplementedError("Please implement this function in derived classes")
37 38 39 40 41 42

    def get_shape(self):
        if self.output is None:
            NotImplementedError("This class was not implemented properly")
        else:
            return self.output.get_shape()