Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
be9ec34c
Commit
be9ec34c
authored
6 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add FaustFactory.rand() in pyfaust and matfaust. Update FaustFactory API doc.
parent
1ca0c9f8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wrapper/matlab/+matfaust/@FaustFactory/FaustFactory.m
+37
-1
37 additions, 1 deletion
wrapper/matlab/+matfaust/@FaustFactory/FaustFactory.m
wrapper/python/pyfaust.py
+31
-2
31 additions, 2 deletions
wrapper/python/pyfaust.py
with
68 additions
and
3 deletions
wrapper/matlab/+matfaust/@FaustFactory/FaustFactory.m
+
37
−
1
View file @
be9ec34c
% ======================================================================
%> @brief This factory class provides methods for generating a Faust especially by factorization of a dense matrix.
%>
%> This class gives access to the main factorization algorithms of
%> FAµST. Those algorithms can factorize a dense matrix to a sparse product
%> (i.e. a Faust object).
%>
%> There are two algorithms for factorization.
%>
%> The first one is Palm4MSA :
%> which stands for Proximal Alternating Linearized Minimization for
%> Multi-layer Sparse Approximation. Note that Palm4MSA is not
%> intended to be used directly. You should rather rely on the second algorithm.
%>
%> The second one is the Hierarchical Factorization algorithm:
%> this is the central algorithm to factorize a dense matrix to a Faust.
%> It makes iterative use of Palm4MSA to proceed with the factorization of a given
%> dense matrix.
%>
% ======================================================================
classdef
FaustFactory
properties
(
SetAccess
=
public
)
...
...
@@ -24,7 +44,6 @@ classdef FaustFactory
%> init_facts{1} = zeros(500,32)
%> init_facts{2} = eye(32)
%> M = rand(500, 32)
%> M = data
%> cons = cell(2,1)
%> cons{1} = ConstraintInt(ConstraintName(ConstraintName.SPLIN), 500, 32, 5);
%> cons{2} = ConstraintReal(ConstraintName(ConstraintName.NORMCOL), 32, 32, 1.0);
...
...
@@ -33,6 +52,13 @@ classdef FaustFactory
%> F = FaustFactory.fact_palm4msa(M, params)
%> @endcode
%>
%> F =
%>
%> Faust size 500x32, density 0.22025, nnz_sum 3524, 2 factor(s):
%> - FACTOR 0 (real) DENSE, size 500x32, density 0.15625, nnz 2500
%> - FACTOR 1 (real) DENSE, size 32x32, density 1, nnz 1024
%>
%>
%==========================================================================================
function
F
=
fact_palm4msa
(
m
,
p
)
import
matfaust
.
Faust
...
...
@@ -126,5 +152,15 @@ classdef FaustFactory
cell_facts
{
1
}
=
cell_facts
{
1
}
*
lambda
;
F
=
Faust
(
cell_facts
);
end
%==========================================================================================
%> @brief Generates a random Faust.
%>
%> <p>@b See @b also Faust.rand.
%==========================================================================================
function
F
=
rand
(
varargin
)
import
matfaust
.
Faust
F
=
Faust
.
rand
(
varargin
{:})
end
end
end
This diff is collapsed.
Click to expand it.
wrapper/python/pyfaust.py
+
31
−
2
View file @
be9ec34c
...
...
@@ -928,11 +928,31 @@ class Faust:
return
np
.
dtype
(
np
.
complex
)
class
FaustFactory
:
"""
This factory class provides methods for generating a Faust especially by factorization of a dense matrix.
This class gives access to the main factorization algorithms of
FAµST. Those algorithms can factorize a dense matrix to a sparse product
(i.e. a Faust object).
There are two algorithms for factorization.
The first one is Palm4MSA :
which stands for Proximal Alternating Linearized Minimization for
Multi-layer Sparse Approximation. Note that Palm4MSA is not
intended to be used directly. You should rather rely on the second algorithm.
The second one is the Hierarchical Factorization algorithm:
this is the central algorithm to factorize a dense matrix to a Faust.
It makes iterative use of Palm4MSA to proceed with the factorization of a given
dense matrix.
"""
@staticmethod
def
fact_palm4msa
(
M
,
p
):
"""
Factorizes the matrix M using the parameters set in p.
Factorizes the matrix M
with Palm4MSA algorithm
using the parameters set in p.
Args:
M: the numpy matrix to factorize.
...
...
@@ -981,7 +1001,7 @@ class FaustFactory:
@staticmethod
def
fact_hierarchical
(
M
,
p
):
"""
Factorizes the matrix M using the parameters set in p.
Factorizes the matrix M
with Hierarchical Factorization
using the parameters set in p.
Args:
M: the numpy matrix to factorize.
...
...
@@ -1034,6 +1054,15 @@ class FaustFactory:
raise
ValueError
(
"
p must be a ParamsPalm4MSA object.
"
)
return
Faust
(
core_obj
=
FaustCorePy
.
FaustFact
.
fact_hierarchical
(
M
,
p
))
@staticmethod
def
rand
(
*
kwargs
):
"""
Generates a random Faust.
<b/> See also Faust.rand
"""
return
Faust
.
rand
(
*
kwargs
)
class
ParamsFact
(
object
):
def
__init__
(
self
,
num_facts
,
is_update_way_R2L
,
init_lambda
,
init_facts
,
...
...
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