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.pad.base
Commits
287abb39
Commit
287abb39
authored
Mar 02, 2018
by
Guillaume HEUSCH
Browse files
[algorithm] fixed precision criterion to stop training
parent
2df027e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/pad/base/algorithm/MLP.py
View file @
287abb39
...
...
@@ -38,7 +38,6 @@ class MLP(Algorithm):
# The data
batch_size
=
len
(
training_features
[
0
])
+
len
(
training_features
[
1
])
print
(
batch_size
)
label_real
=
numpy
.
ones
((
len
(
training_features
[
0
]),
1
),
dtype
=
'float64'
)
label_attack
=
numpy
.
zeros
((
len
(
training_features
[
1
]),
1
),
dtype
=
'float64'
)
...
...
@@ -68,12 +67,12 @@ class MLP(Algorithm):
previous_cost
=
0
current_cost
=
1
precision
=
0.001
while
(
n_iter
<
self
.
max_iter
)
or
(
abs
(
previous_cost
-
current_cost
)
<
precision
):
while
(
n_iter
<
self
.
max_iter
)
or
(
abs
(
previous_cost
-
current_cost
)
>
precision
):
previous_cost
=
current_cost
trainer
.
train
(
self
.
mlp
,
X
,
Y
)
current_cost
=
trainer
.
cost
(
self
.
mlp
,
X
,
Y
)
n_iter
+=
1
print
(
"Iteration {} -> cost = {} (previous = {})"
.
format
(
n_iter
,
trainer
.
cost
(
self
.
mlp
,
X
,
Y
),
previous_cost
))
#
print("Iteration {} -> cost = {} (previous = {})".format(n_iter, trainer.cost(self.mlp, X, Y), previous_cost))
f
=
bob
.
io
.
base
.
HDF5File
(
projector_file
,
'w'
)
self
.
mlp
.
save
(
f
)
...
...
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