Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CSNMF
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
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
TrafficPatterns
CSNMF
Commits
5b338be2
Commit
5b338be2
authored
6 years ago
by
yager2
Browse files
Options
Downloads
Patches
Plain Diff
Replace cSNMF.py. Contains modification to allow W initialization and option to turn of update_W
parent
237334c5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Multiplicative Algorithm/cSNMF.py
+13
-4
13 additions, 4 deletions
Multiplicative Algorithm/cSNMF.py
with
13 additions
and
4 deletions
Multiplicative Algorithm/cSNMF.py
+
13
−
4
View file @
5b338be2
...
@@ -90,6 +90,7 @@ def sort_WH(W, H):
...
@@ -90,6 +90,7 @@ def sort_WH(W, H):
def
factorize
(
data_array
,
def
factorize
(
data_array
,
init_W
=
None
,
rank
=
config
.
RANK
,
rank
=
config
.
RANK
,
beta
=
None
,
beta
=
None
,
threshold
=
0.5
,
threshold
=
0.5
,
...
@@ -98,7 +99,8 @@ def factorize(data_array,
...
@@ -98,7 +99,8 @@ def factorize(data_array,
seed_H
=
None
,
seed_H
=
None
,
log
=
logger
,
log
=
logger
,
debug
=
False
,
debug
=
False
,
axing
=
True
):
axing
=
True
,
update_W
=
True
):
log
.
info
(
'
Rank= %s, Threshold= %s
'
,
rank
,
threshold
)
log
.
info
(
'
Rank= %s, Threshold= %s
'
,
rank
,
threshold
)
...
@@ -136,8 +138,12 @@ def factorize(data_array,
...
@@ -136,8 +138,12 @@ def factorize(data_array,
W_shape
=
(
D
.
shape
[
0
],
rank
)
W_shape
=
(
D
.
shape
[
0
],
rank
)
H_shape
=
(
rank
,
D
.
shape
[
1
])
H_shape
=
(
rank
,
D
.
shape
[
1
])
np
.
random
.
seed
(
seed_W
)
if
init_W
is
None
:
W
=
np
.
random
.
uniform
(
low
=
0.01
,
high
=
1.
,
size
=
W_shape
)
np
.
random
.
seed
(
seed_W
)
W
=
np
.
random
.
uniform
(
low
=
0.01
,
high
=
1.
,
size
=
W_shape
)
else
:
W
=
init_W
np
.
random
.
seed
(
seed_H
)
np
.
random
.
seed
(
seed_H
)
H
=
np
.
random
.
uniform
(
low
=
0.01
,
high
=
1.
,
size
=
H_shape
)
H
=
np
.
random
.
uniform
(
low
=
0.01
,
high
=
1.
,
size
=
H_shape
)
log
.
info
(
'
W, H chosen
'
)
log
.
info
(
'
W, H chosen
'
)
...
@@ -158,7 +164,10 @@ def factorize(data_array,
...
@@ -158,7 +164,10 @@ def factorize(data_array,
if
iterations
>
max_iter
:
if
iterations
>
max_iter
:
break
break
W_new
=
update_W
(
W
,
H
)
if
update_W
:
W_new
=
update_W
(
W
,
H
)
else
:
W_new
=
W
H_new
=
update_H
(
W_new
,
H
)
H_new
=
update_H
(
W_new
,
H
)
# Check for nonnegativity
# Check for nonnegativity
...
...
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