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.bio.gmm
Commits
cb906338
Commit
cb906338
authored
Apr 13, 2018
by
Tiago de Freitas Pereira
Browse files
Reseted the pseudo random number generator
parent
3bc86678
Changes
4
Hide whitespace changes
Inline
Side-by-side
bob/bio/gmm/algorithm/GMM.py
View file @
cb906338
...
...
@@ -112,6 +112,10 @@ class GMM (Algorithm):
# Trains using the KMeansTrainer
logger
.
info
(
" -> Training K-Means"
)
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
self
.
rng
self
.
rng
=
bob
.
core
.
random
.
mt19937
(
self
.
init_seed
)
bob
.
learn
.
em
.
train
(
self
.
kmeans_trainer
,
kmeans
,
array
,
self
.
kmeans_training_iterations
,
self
.
training_threshold
,
rng
=
self
.
rng
)
variances
,
weights
=
kmeans
.
get_variances_and_weights_for_each_cluster
(
array
)
...
...
@@ -125,6 +129,9 @@ class GMM (Algorithm):
# Trains the GMM
logger
.
info
(
" -> Training GMM"
)
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
self
.
rng
self
.
rng
=
bob
.
core
.
random
.
mt19937
(
self
.
init_seed
)
bob
.
learn
.
em
.
train
(
self
.
ubm_trainer
,
self
.
ubm
,
array
,
self
.
gmm_training_iterations
,
self
.
training_threshold
,
rng
=
self
.
rng
)
...
...
@@ -198,7 +205,7 @@ class GMM (Algorithm):
logger
.
debug
(
" .... Enrolling with %d feature vectors"
,
array
.
shape
[
0
])
gmm
=
bob
.
learn
.
em
.
GMMMachine
(
self
.
ubm
)
gmm
.
set_variance_thresholds
(
self
.
variance_threshold
)
gmm
.
set_variance_thresholds
(
self
.
variance_threshold
)
bob
.
learn
.
em
.
train
(
self
.
enroll_trainer
,
gmm
,
array
,
self
.
gmm_enroll_iterations
,
self
.
training_threshold
,
rng
=
self
.
rng
)
return
gmm
...
...
bob/bio/gmm/algorithm/ISV.py
View file @
cb906338
...
...
@@ -64,6 +64,9 @@ class ISV (GMM):
logger
.
info
(
" -> Training ISV enroller"
)
self
.
isvbase
=
bob
.
learn
.
em
.
ISVBase
(
self
.
ubm
,
self
.
subspace_dimension_of_u
)
# train ISV model
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
self
.
rng
self
.
rng
=
bob
.
core
.
random
.
mt19937
(
self
.
init_seed
)
bob
.
learn
.
em
.
train
(
self
.
isv_trainer
,
self
.
isvbase
,
data
,
self
.
isv_training_iterations
,
rng
=
self
.
rng
)
...
...
bob/bio/gmm/algorithm/IVector.py
View file @
cb906338
...
...
@@ -94,6 +94,10 @@ class IVector (GMM):
logger
.
info
(
" -> Training IVector enroller"
)
self
.
tv
=
bob
.
learn
.
em
.
IVectorMachine
(
self
.
ubm
,
self
.
subspace_dimension_of_t
,
self
.
variance_threshold
)
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
self
.
rng
self
.
rng
=
bob
.
core
.
random
.
mt19937
(
self
.
init_seed
)
# train IVector model
bob
.
learn
.
em
.
train
(
self
.
ivector_trainer
,
self
.
tv
,
training_stats
,
self
.
tv_training_iterations
,
rng
=
self
.
rng
)
...
...
@@ -125,6 +129,11 @@ class IVector (GMM):
variance_flooring
=
1e-5
training_features
=
[
numpy
.
vstack
(
client
)
for
client
in
training_features
]
input_dim
=
training_features
[
0
].
shape
[
1
]
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
self
.
rng
self
.
rng
=
bob
.
core
.
random
.
mt19937
(
self
.
init_seed
)
self
.
plda_base
=
bob
.
learn
.
em
.
PLDABase
(
input_dim
,
self
.
plda_dim_F
,
self
.
plda_dim_G
,
variance_flooring
)
bob
.
learn
.
em
.
train
(
self
.
plda_trainer
,
self
.
plda_base
,
training_features
,
self
.
plda_training_iterations
,
rng
=
self
.
rng
)
...
...
bob/bio/gmm/tools/gmm.py
View file @
cb906338
...
...
@@ -32,6 +32,10 @@ def kmeans_initialize(algorithm, extractor, limit_data = None, force = False, al
# Perform KMeans initialization
kmeans_machine
=
bob
.
learn
.
em
.
KMeansMachine
(
algorithm
.
gaussians
,
data
.
shape
[
1
])
# Creates the KMeansTrainer and call the initialization procedure
# Reseting the pseudo random number generator so we can have the same initialization for serial and parallel execution.
del
algorithm
.
rng
algorithm
.
rng
=
bob
.
core
.
random
.
mt19937
(
algorithm
.
init_seed
)
algorithm
.
kmeans_trainer
.
initialize
(
kmeans_machine
,
data
,
algorithm
.
rng
)
bob
.
io
.
base
.
create_directories_safe
(
os
.
path
.
dirname
(
output_file
))
kmeans_machine
.
save
(
bob
.
io
.
base
.
HDF5File
(
output_file
,
'w'
))
...
...
Write
Preview
Markdown
is supported
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