Skip to content
Snippets Groups Projects
Commit fdfa63eb authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Created average pooling

parent 3ed2c592
No related branches found
No related tags found
No related merge requests found
#!/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
import tensorflow as tf
from bob.learn.tensorflow.util import *
from .MaxPooling import MaxPooling
class AveragePooling(MaxPooling):
def __init__(self, name, shape=[1, 2, 2, 1],
strides=[1, 1, 1, 1],
batch_norm=False,
activation=None):
"""
Constructor
"""
super(AveragePooling, self).__init__(name, activation=activation, batch_norm=batch_norm)
self.shape = shape
self.strides = strides
def get_graph(self, training_phase=True):
with tf.name_scope(str(self.name)):
output = tf.nn.avg_pool(self.input_layer, ksize=self.shape, strides=self.strides, padding='SAME')
if self.batch_norm:
output = self.batch_normalize(output, training_phase)
if self.activation is not None:
output = self.activation(output)
return output
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment