Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
fdfa63eb
Commit
fdfa63eb
authored
Nov 04, 2016
by
Tiago de Freitas Pereira
Browse files
Created average pooling
parent
3ed2c592
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/layers/AveragePooling.py
0 → 100644
View file @
fdfa63eb
#!/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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment