Skip to content
GitLab
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
bdbc9988
Commit
bdbc9988
authored
Oct 12, 2017
by
Tiago de Freitas Pereira
Browse files
Changed LightCNN to functions issue
#37
parent
ad6a9bba
Pipeline
#13139
failed with stages
in 6 minutes and 38 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/network/LightCNN29.py
View file @
bdbc9988
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Wed 11 May 2016 09:39:36 CEST
import
tensorflow
as
tf
from
bob.learn.tensorflow.layers
import
maxout
...
...
bob/learn/tensorflow/network/LightCNN9.py
View file @
bdbc9988
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
# @date: Wed 11 May 2016 09:39:36 CEST
import
tensorflow
as
tf
from
bob.learn.tensorflow.layers
import
maxout
from
.utils
import
append_logits
class
LightCNN9
(
object
):
def
light_cnn9
(
inputs
,
seed
=
10
,
reuse
=
False
):
"""Creates the graph for the Light CNN-9 in
Wu, Xiang, et al. "A light CNN for deep face representation with noisy labels." arXiv preprint arXiv:1511.02683 (2015).
"""
def
__init__
(
self
,
seed
=
10
,
n_classes
=
10
):
slim
=
tf
.
contrib
.
slim
self
.
seed
=
seed
self
.
n_classes
=
n_classes
with
tf
.
variable_scope
(
'LightCNN9'
,
reuse
=
reuse
):
def
__call__
(
self
,
inputs
,
reuse
=
False
,
get_class_layer
=
True
,
end_point
=
"logits"
):
slim
=
tf
.
contrib
.
slim
#with tf.device(self.device):
initializer
=
tf
.
contrib
.
layers
.
xavier_initializer
(
uniform
=
False
,
dtype
=
tf
.
float32
,
seed
=
self
.
seed
)
initializer
=
tf
.
contrib
.
layers
.
xavier_initializer
(
uniform
=
False
,
dtype
=
tf
.
float32
,
seed
=
seed
)
end_points
=
dict
()
graph
=
slim
.
conv2d
(
inputs
,
96
,
[
5
,
5
],
activation_fn
=
tf
.
nn
.
relu
,
...
...
@@ -141,24 +132,14 @@ class LightCNN9(object):
graph
=
slim
.
flatten
(
graph
,
scope
=
'flatten1'
)
end_points
[
'flatten1'
]
=
graph
graph
=
slim
.
dropout
(
graph
,
keep_prob
=
0.
3
,
scope
=
'dropout1'
)
graph
=
slim
.
dropout
(
graph
,
keep_prob
=
0.
5
,
scope
=
'dropout1'
)
graph
=
slim
.
fully_connected
(
graph
,
512
,
prelogits
=
slim
.
fully_connected
(
graph
,
512
,
weights_initializer
=
initializer
,
activation_fn
=
tf
.
nn
.
relu
,
scope
=
'fc1'
,
reuse
=
reuse
)
end_points
[
'fc1'
]
=
graph
#graph = maxout(graph,
# num_units=256,
# name='Maxoutfc1')
graph
=
slim
.
dropout
(
graph
,
keep_prob
=
0.3
,
scope
=
'dropout2'
)
if
self
.
n_classes
is
not
None
:
# Appending the logits layer
graph
=
append_logits
(
graph
,
self
.
n_classes
,
reuse
)
end_points
[
'logits'
]
=
graph
end_points
[
'fc1'
]
=
prelogits
return
end_points
[
end_point
]
return
prelogits
,
end_point
s
bob/learn/tensorflow/network/__init__.py
View file @
bdbc9988
from
.Chopra
import
chopra
from
.LightCNN9
import
L
ight
CNN
9
from
.LightCNN9
import
l
ight
_cnn
9
from
.LightCNN29
import
LightCNN29
from
.Dummy
import
Dummy
from
.MLP
import
MLP
...
...
@@ -24,7 +24,7 @@ def __appropriate__(*args):
__appropriate__
(
Chopra
,
L
ight
CNN
9
,
l
ight
_cnn
9
,
Dummy
,
MLP
,
)
...
...
bob/learn/tensorflow/test/test_cnn_other_losses.py
View file @
bdbc9988
...
...
@@ -120,7 +120,7 @@ def test_center_loss_tfrecord_embedding_validation():
prelogits
=
prelogits
)
trainer
.
train
()
assert
True
tf
.
reset_default_graph
()
del
trainer
...
...
bob/learn/tensorflow/trainers/Trainer.py
View file @
bdbc9988
...
...
@@ -483,8 +483,8 @@ class Trainer(object):
# Appending histograms for each trainable variables
#for var in tf.trainable_variables():
for
var
in
tf
.
global_variables
():
tf
.
summary
.
histogram
(
var
.
op
.
name
,
var
)
#
for var in tf.global_variables():
#
tf.summary.histogram(var.op.name, var)
# Train summary
tf
.
summary
.
scalar
(
'loss'
,
average_loss
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment