Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nonnegative Factorization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MARMORET Axel
Nonnegative Factorization
Commits
f1c328f3
Commit
f1c328f3
authored
1 year ago
by
MARMORET Axel
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes (name changing mainly)
parent
1ec1475c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
nn_fac/update_rules/min_vol_mu.py
+6
-6
6 additions, 6 deletions
nn_fac/update_rules/min_vol_mu.py
with
6 additions
and
6 deletions
nn_fac/update_rules/min_vol_mu.py
+
6
−
6
View file @
f1c328f3
import
warnings
import
numpy
as
np
from
nn_fac.utils.normalize_wh
import
normalize_
WH
import
nn_fac.utils.normalize_wh
as
normalize_
wh
from
nn_fac.utils.beta_divergence
import
beta_divergence
eps
=
1e-12
...
...
@@ -27,7 +27,7 @@ def KL_mu_min_vol(data, W, H, delta, lambda_, gamma = None, tol_update_lagrangia
else
:
lagragian_multipliers_0
=
np
.
zeros
((
k
,
1
))
#(D[:,0] - C[:,0] * W[:,0]).T
lagragian_multipliers
=
update_lagragian_multipliers
(
C
,
S
,
D
,
W
,
lagragian_multipliers_0
,
tol_update_lagrangian
)
lagragian_multipliers
=
update_lagragian_multipliers
_Wminvol
(
C
,
S
,
D
,
W
,
lagragian_multipliers_0
,
tol_update_lagrangian
)
W
=
W
*
((((
C
+
Jm1
@
lagragian_multipliers
.
T
)
**
2
+
S
)
**
0.5
-
(
C
+
Jm1
@
lagragian_multipliers
.
T
))
/
(
D
+
eps
))
...
...
@@ -44,15 +44,15 @@ def gamma_line_search(data, W_update, W_gamma_init, H_gamma_init, beta, delta, g
while
cur_err
>
prev_error
and
gamma
>
1e-16
:
gamma
*=
0.8
W_gamma
=
(
1
-
gamma
)
*
W_prev
+
gamma
*
W_update
W_gamma
,
H_gamma
=
normalize_WH
(
W_gamma
,
H_gamma
,
"
W
"
)
W_gamma
,
H_gamma
=
normalize_wh
.
normalize_WH
(
W_gamma
,
H_gamma
,
"
W
"
)
cur_log_det
=
compute_log_det
(
W_gamma
,
delta
)
cur_err
=
beta_divergence
(
data
,
W_gamma
@
H_gamma
,
beta
)
+
lambda_tilde
*
cur_log_det
gamma
=
min
(
gamma
*
1.2
,
1
)
return
W_gamma
,
H_gamma
,
gamma
def
update_lagragian_multipliers
(
C
,
S
,
D
,
W
,
lagrangian_multipliers_0
,
tol
=
1e-6
,
n_iter_max
=
100
0
):
# Comes from
def
update_lagragian_multipliers
_Wminvol
(
C
,
S
,
D
,
W
,
lagrangian_multipliers_0
,
tol
=
1e-6
,
n_iter_max
=
100
):
# Comes from
Multiplicative Updates for NMF with β-Divergences under Disjoint Equality Constraints, https://arxiv.org/pdf/2010.16223.pdf
m
,
k
=
W
.
shape
Jm1
=
np
.
ones
((
m
,
1
))
Jk1
=
np
.
ones
(
k
)
...
...
@@ -74,7 +74,7 @@ def update_lagragian_multipliers(C, S, D, W, lagrangian_multipliers_0, tol = 1e-
break
if
iter
==
n_iter_max
-
1
:
warnings
.
warn
(
'
Maximum of iterations reached in the update of
mu
.
'
)
warnings
.
warn
(
'
Maximum of iterations reached in the update of
the Lagrangian multipliers
.
'
)
return
lagrangian_multipliers
...
...
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