Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
60945e02
Commit
60945e02
authored
4 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
remove the layers folder
parent
1e21e10c
No related branches found
No related tags found
1 merge request
!85
Porting to TF2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/tensorflow/layers/Maxout.py
+0
-74
0 additions, 74 deletions
bob/learn/tensorflow/layers/Maxout.py
bob/learn/tensorflow/layers/__init__.py
+0
-24
0 additions, 24 deletions
bob/learn/tensorflow/layers/__init__.py
with
0 additions
and
98 deletions
bob/learn/tensorflow/layers/Maxout.py
deleted
100644 → 0
+
0
−
74
View file @
1e21e10c
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Fri 04 Aug 2017 14:14:22 CEST
# MAXOUT IMPLEMENTED FOR TENSORFLOW
from
tensorflow.python.layers
import
base
import
tensorflow
as
tf
def
maxout
(
inputs
,
num_units
,
axis
=-
1
,
name
=
None
):
return
Maxout
(
num_units
=
num_units
,
axis
=
axis
,
name
=
name
)(
inputs
)
class
Maxout
(
base
.
Layer
):
"""
Adds a maxout op from
"
Maxout Networks
"
Ian J. Goodfellow, David Warde-Farley, Mehdi Mirza, Aaron Courville, Yoshua
Bengio
Usually the operation is performed in the filter/channel dimension. This can also be
used after fully-connected layers to reduce number of features.
**Parameters**
inputs: Tensor input
num_units: Specifies how many features will remain after maxout in the `axis` dimension (usually channel).
This must be multiple of number of `axis`.
axis: The dimension where max pooling will be performed. Default is the
last dimension.
name: Optional scope for name_scope.
"""
def
__init__
(
self
,
num_units
,
axis
=-
1
,
name
=
None
,
**
kwargs
):
super
(
Maxout
,
self
).
__init__
(
name
=
name
,
trainable
=
False
,
**
kwargs
)
self
.
axis
=
axis
self
.
num_units
=
num_units
def
call
(
self
,
inputs
,
training
=
False
):
inputs
=
tf
.
convert_to_tensor
(
inputs
)
shape
=
inputs
.
get_shape
().
as_list
()
# Dealing with batches with arbitrary sizes
for
i
in
range
(
len
(
shape
)):
if
shape
[
i
]
is
None
:
shape
[
i
]
=
tf
.
shape
(
inputs
)[
i
]
num_channels
=
shape
[
self
.
axis
]
if
not
isinstance
(
num_channels
,
tf
.
Tensor
)
and
num_channels
%
self
.
num_units
:
raise
ValueError
(
"
number of features({}) is not
"
"
a multiple of num_units({})
"
.
format
(
num_channels
,
self
.
num_units
)
)
if
self
.
axis
<
0
:
axis
=
self
.
axis
+
len
(
shape
)
else
:
axis
=
self
.
axis
assert
axis
>=
0
,
"
Find invalid axis: {}
"
.
format
(
self
.
axis
)
expand_shape
=
shape
[:]
expand_shape
[
axis
]
=
self
.
num_units
k
=
num_channels
//
self
.
num_units
expand_shape
.
insert
(
axis
,
k
)
outputs
=
tf
.
math
.
reduce_max
(
tf
.
reshape
(
inputs
,
expand_shape
),
axis
,
keepdims
=
False
)
return
outputs
This diff is collapsed.
Click to expand it.
bob/learn/tensorflow/layers/__init__.py
deleted
100644 → 0
+
0
−
24
View file @
1e21e10c
from
.Maxout
import
Maxout
,
maxout
# gets sphinx autodoc done right - don't remove it
def
__appropriate__
(
*
args
):
"""
Says object was actually declared here, an not on the import module.
Parameters:
*args: An iterable of objects to modify
Resolves `Sphinx referencing issues
<https://github.com/sphinx-doc/sphinx/issues/3048>`
"""
for
obj
in
args
:
obj
.
__module__
=
__name__
__appropriate__
(
Maxout
,
maxout
,
)
__all__
=
[
_
for
_
in
dir
()
if
not
_
.
startswith
(
'
_
'
)]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment