Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.em
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
Package registry
Model registry
Operate
Environments
Terraform modules
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.em
Commits
4c590745
Commit
4c590745
authored
3 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
[doc] fix doctests for ISV and JFA
parent
c0433365
No related branches found
No related tags found
1 merge request
!53
Factor Analysis on pure python
Pipeline
#60450
passed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/guide.rst
+14
-38
14 additions, 38 deletions
doc/guide.rst
with
14 additions
and
38 deletions
doc/guide.rst
+
14
−
38
View file @
4c590745
...
...
@@ -329,33 +329,21 @@ The snippet bellow shows how to:
>>> data_class2 = np.random.normal(-0.2, 0.2, (10, 3))
>>> X = np.vstack((data_class1, data_class2))
>>> y = np.hstack((np.zeros(10, dtype=int), np.ones(10, dtype=int)))
>>> # Training an UBM with 2 gaussians
>>> ubm = bob.learn.em.GMMMachine(2).fit(X)
>>> # The input the the ISV Training is the statistics of the GMM
>>> # Here we are creating a GMMStats for each datapoints, which is NOT usual,
>>> # but it is done for testing purposes
>>> gmm_stats = [ubm.transform(x[np.newaxis]) for x in X]
>>> # Finally doing the ISV training with U subspace with dimension of 2
>>> isv_machine = bob.learn.em.ISVMachine(ubm, r_U=2).fit(gmm_stats, y)
>>> print(isv_machine.U)
[[-0.079 -0.011]
[ 0.078 0.039]
[ 0.129 0.018]
[ 0.175 0.254]
[ 0.019 0.027]
[-0.132 -0.191]]
>>> # Create an ISV machine with a UBM of 2 gaussians
>>> isv_machine = bob.learn.em.ISVMachine(r_U=2, ubm_kwargs=dict(n_gaussians=2))
>>> _ = isv_machine.fit(X, y) # DOCTEST: +SKIP_
>>> isv_machine.U
array(...)
>>> # Enrolling a subject
>>> enroll_data = np.array([[1.2, 0.1, 1.4], [0.5, 0.2, 0.3]])
>>> model = isv_machine.enroll
_with_array
(enroll_data)
>>> model = isv_machine.enroll(enroll_data)
>>> print(model)
[[ 0.54 0.246 0.505 1.617 -0.791 0.746]]
>>> # Probing
>>> probe_data = np.array([[1.2, 0.1, 1.4], [0.5, 0.2, 0.3]])
>>> score = isv_machine.score
_with_array
(model, probe_data)
>>> score = isv_machine.score(model, probe_data)
>>> print(score)
[2.754]
...
...
@@ -404,31 +392,19 @@ such session variability model.
>>> data_class2 = np.random.normal(-0.2, 0.2, (10, 3))
>>> X = np.vstack((data_class1, data_class2))
>>> y = np.hstack((np.zeros(10, dtype=int), np.ones(10, dtype=int)))
>>> # Training an UBM with 2 gaussians
>>> ubm = bob.learn.em.GMMMachine(2).fit(X)
>>> # The input the the JFA Training is the statistics of the GMM
>>> # Here we are creating a GMMStats for each datapoints, which is NOT usual,
>>> # but it is done for testing purposes
>>> gmm_stats = [ubm.transform(x[np.newaxis]) for x in X]
>>> # Finally doing the JFA training with U and V subspaces with dimension of 2
>>> jfa_machine = bob.learn.em.JFAMachine(ubm, r_U=2, r_V=2).fit(gmm_stats, y)
>>> print(jfa_machine.U)
[[-0.069 -0.029]
[ 0.079 0.039]
[ 0.123 0.042]
[ 0.17 0.255]
[ 0.018 0.027]
[-0.128 -0.192]]
>>> # Create a JFA machine with a UBM of 2 gaussians
>>> jfa_machine = bob.learn.em.JFAMachine(r_U=2, r_V=2, ubm_kwargs=dict(n_gaussians=2))
>>> _ = jfa_machine.fit(X, y)
>>> jfa_machine.U
array(...)
>>> enroll_data = np.array([[1.2, 0.1, 1.4], [0.5, 0.2, 0.3]])
>>> model = jfa_machine.enroll
_with_array
(enroll_data)
>>> model = jfa_machine.enroll(enroll_data)
>>> print(model)
(array([0.634, 0.165]), array([ 0., 0., 0., 0., -0., 0.]))
>>> probe_data = np.array([[1.2, 0.1, 1.4], [0.5, 0.2, 0.3]])
>>> score = jfa_machine.score
_with_array
(model, probe_data)
>>> score = jfa_machine.score(model, probe_data)
>>> print(score)
[0.471]
...
...
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