Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.mlp
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
Show more breadcrumbs
bob
bob.learn.mlp
Commits
1a3ac8d1
Commit
1a3ac8d1
authored
10 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Also test randomization using the same seed for equality
parent
b768b2f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xbob/learn/mlp/machine.cpp
+1
-1
1 addition, 1 deletion
xbob/learn/mlp/machine.cpp
xbob/learn/mlp/test_machine.py
+24
-4
24 additions, 4 deletions
xbob/learn/mlp/test_machine.py
with
25 additions
and
5 deletions
xbob/learn/mlp/machine.cpp
+
1
−
1
View file @
1a3ac8d1
...
...
@@ -976,7 +976,7 @@ static PyObject* PyBobLearnMLPMachine_Randomize
PyBoostMt19937Object
*
rng
=
0
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|ddO!"
,
kwlist
,
&
lower_bound
,
&
upper_bound
,
&
PyBoostMt19937_
Check
,
&
rng
))
return
0
;
&
lower_bound
,
&
upper_bound
,
&
PyBoostMt19937_
Type
,
&
rng
))
return
0
;
if
(
rng
)
{
self
->
cxx
->
randomize
(
*
rng
->
rng
,
lower_bound
,
upper_bound
);
...
...
This diff is collapsed.
Click to expand it.
xbob/learn/mlp/test_machine.py
+
24
−
4
View file @
1a3ac8d1
...
...
@@ -18,6 +18,7 @@ from .test_utils import Machine as PythonMachine
import
xbob.io
from
xbob.io.test_utils
import
temporary_filename
from
xbob.learn.activation
import
Logistic
,
HyperbolicTangent
from
xbob.core.random
import
mt19937
def
test_2in_1out
():
...
...
@@ -265,18 +266,37 @@ def test_randomization_margins():
assert
(
abs
(
k
)
<=
0.001
).
all
()
assert
(
k
!=
0
).
any
()
def
test_randomness
():
def
test_randomness
_different
():
m1
=
Machine
((
2
,
3
,
2
))
m1
.
randomize
()
for
k
in
range
(
10
):
for
k
in
range
(
3
):
time
.
sleep
(
0.1
)
m2
=
Machine
((
2
,
3
,
2
))
m2
.
randomize
()
for
w1
,
w2
in
zip
(
m1
.
weights
,
m2
.
weights
):
nose
.
tools
.
eq_
((
w1
==
w2
).
all
(),
False
)
assert
not
(
w1
==
w2
).
all
()
for
b1
,
b2
in
zip
(
m1
.
biases
,
m2
.
biases
):
assert
not
(
b1
==
b2
).
all
()
def
test_randomness_same
():
m1
=
Machine
((
2
,
3
,
2
))
rng
=
xbob
.
core
.
random
.
mt19937
(
0
)
#fixed seed
m1
.
randomize
(
rng
=
rng
)
for
k
in
range
(
3
):
time
.
sleep
(
0.1
)
m2
=
Machine
((
2
,
3
,
2
))
rng
=
xbob
.
core
.
random
.
mt19937
(
0
)
#fixed seed
m2
.
randomize
(
rng
=
rng
)
for
w1
,
w2
in
zip
(
m1
.
weights
,
m2
.
weights
):
assert
(
w1
==
w2
).
all
()
for
b1
,
b2
in
zip
(
m1
.
biases
,
m2
.
biases
):
nose
.
tools
.
eq_
(
(
b1
==
b2
).
all
()
,
False
)
assert
(
b1
==
b2
).
all
()
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