MaxPooling.py 711 Bytes
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
from bob.learn.tensorflow.util import *
from .Layer import Layer


class MaxPooling(Layer):

13
    def __init__(self, name, use_gpu=False):
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
14 15 16
        """
        Constructor
        """
17 18 19 20 21
        super(MaxPooling, self).__init__(name, use_gpu=False)

    def create_variables(self, input):
        self.input = input
        return
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
22 23

    def get_graph(self):
24 25 26 27
        with tf.name_scope(str(self.name)):
            self.output = tf.nn.max_pool(self.input, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')

        return self.output