Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6d3d5f65 authored by hhakim's avatar hhakim
Browse files

Modify matfaust.factparams.ParamsFact and sub-classes to decrease the number...

Modify matfaust.factparams.ParamsFact and sub-classes to decrease the number of mandatory arguments.

- The minimal set of arguments is the constraints + stopping criterion/criteria both for PALM4MSA and Hierarchical algos.
- The other arguments are optional thus they are set to their default values if not specified.
- The definition of default arguments is made in a keyword-value pair fashion; 'keyword1', value1, 'keyword2', value2. It resembles the way python authorizes keyword arguments after positional arguments. Likewise first arguments (constraints and StoppingCriterion-s) are mandatory so they are positional.
- The num_facts argument (number of factors of the factorization resulting product) is now deduced from the number of constraints. It avoids inconsistent setting of desired number of factors and number of constraints. But future simplified parametrization still will be able to define a targeted number of factors.
- Refactoring has been made for consistency and reusability between ParamsPalm4MSA, ParamsHierarchicalFact and their parent class ParamsFact.
parent 688c6b34
Branches
Tags
No related merge requests found
......@@ -36,7 +36,8 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
cons{1} = ConstraintInt(ConstraintName(ConstraintName.SPLIN), 500, 32, 5);
cons{2} = ConstraintReal(ConstraintName(ConstraintName.NORMCOL), 32, 32, 1.0);
stop_crit = StoppingCriterion(200);
params = ParamsPalm4MSA(num_facts, is_update_way_R2L, init_lambda, cons, stop_crit, init_facts, ParamsFact.DEFAULT_STEP_SIZE, ParamsFact.DEFAULT_CONSTANT_STEP_SIZE);
params = ParamsPalm4MSA(cons, stop_crit, 'is_update_way_R2L', is_update_way_R2L, 'init_lambda', init_lambda, 'step_size', ParamsFact.DEFAULT_STEP_SIZE,...
'constant_step_size', ParamsFact.DEFAULT_CONSTANT_STEP_SIZE);
F = FaustFactory.fact_palm4msa(M, params)
this.verifyEqual(size(F), size(M))
%disp('norm F: ')
......@@ -67,7 +68,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
cons{1} = ConstraintInt(ConstraintName(ConstraintName.SPLIN), 500, 32, 5);
cons{2} = ConstraintReal(ConstraintName(ConstraintName.NORMCOL), 32, 32, 1.0);
stop_crit = StoppingCriterion(200);
params = ParamsPalm4MSA(num_facts, is_update_way_R2L, init_lambda, cons, stop_crit, init_facts, ParamsFact.DEFAULT_STEP_SIZE, ParamsFact.DEFAULT_CONSTANT_STEP_SIZE);
params = ParamsPalm4MSA(cons, stop_crit, 'is_update_way_R2L', is_update_way_R2L, 'init_lambda', init_lambda);
F = FaustFactory.fact_palm4msa(M, params)
this.verifyEqual(size(F), size(M))
%disp('norm F: ')
......@@ -104,8 +105,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
res_cons{3} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 333);
stop_crit = StoppingCriterion(200);
stop_crit2 = StoppingCriterion(200);
params = ParamsHierarchicalFact(num_facts, is_update_way_R2L, init_lambda,...
fact_cons, res_cons, {stop_crit, stop_crit2});
params = ParamsHierarchicalFact(fact_cons, res_cons, stop_crit, stop_crit2);
F = FaustFactory.fact_hierarchical(M, params)
this.verifyEqual(size(F), size(M))
%disp('norm F: ')
......@@ -144,8 +144,8 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
res_cons{3} = ConstraintInt(ConstraintName(ConstraintName.SP), 32, 32, 333);
stop_crit = StoppingCriterion(200);
stop_crit2 = StoppingCriterion(200);
params = ParamsHierarchicalFact(num_facts, is_update_way_R2L, init_lambda,...
fact_cons, res_cons, {stop_crit, stop_crit2});
params = ParamsHierarchicalFact(fact_cons, res_cons, stop_crit, stop_crit2,...
'init_lambda', init_lambda, 'is_update_way_R2L', is_update_way_R2L);
F = FaustFactory.fact_hierarchical(M, params)
this.verifyEqual(size(F), size(M))
%disp('norm F: ')
......@@ -184,7 +184,7 @@ classdef FaustFactoryTest < matlab.unittest.TestCase
fF = full(F);
fftI = fft(eye(2^n));
% this.verifyEqual(nnz(fH), numel(fH));
this.verifyEqual(norm(fF-fftI), 0, 'AbsTol',10^-13);
this.verifyEqual(norm(fF-fftI), 0, 'AbsTol',10^-12);
end
end
......
......@@ -11,63 +11,84 @@ classdef (Abstract) ParamsFact
constraints
is_verbose
end
properties (Constant)
properties (Constant, SetAccess = public)
DEFAULT_STEP_SIZE = 10^-16
DEFAULT_VERBOSITY = false
DEFAULT_CONSTANT_STEP_SIZE = false
DEFAULT_INIT_LAMBDA = 1.0
DEFAULT_IS_UPDATE_WAY_R2L = false
% constructor opt. arguments indices
IDX_IS_UPDATE_WAY_R2L = 1
IDX_INIT_LAMBDA = 2
IDX_STEP_SIZE = 3
IDX_CONSTANT_STEP_SIZE = 4
IDX_VERBOSITY = 5
% the order of names matters and must respect the indices above
OPT_ARG_NAMES = {'is_update_way_R2L', 'init_lambda', 'step_size', 'constant_step_size', 'is_verbose'}
end
methods
function p = ParamsFact(varargin)
MIN_NARGIN = 4;
if(nargin < MIN_NARGIN)
error(['matfaust.factparams.ParamsFact() must receive at least ', int2str(MIN_NARGIN),' arguments.'])
end
num_facts = varargin{1};
is_update_way_R2L = varargin{2};
init_lambda = varargin{3};
constraints = varargin{4};
function p = ParamsFact(num_facts, constraints, varargin)
import matfaust.factparams.ParamsFact
% set default values
step_size = matfaust.factparams.ParamsFact.DEFAULT_STEP_SIZE;
is_verbose = matfaust.factparams.ParamsFact.DEFAULT_VERBOSITY;
constant_step_size = matfaust.factparams.ParamsFact.DEFAULT_CONSTANT_STEP_SIZE;
is_update_way_R2L = ParamsFact.DEFAULT_IS_UPDATE_WAY_R2L;
init_lambda = ParamsFact.DEFAULT_INIT_LAMBDA;
step_size = ParamsFact.DEFAULT_STEP_SIZE;
is_verbose = ParamsFact.DEFAULT_VERBOSITY;
constant_step_size = ParamsFact.DEFAULT_CONSTANT_STEP_SIZE;
% check mandatory arguments
if(~ isscalar(num_facts) || ~ isreal(num_facts))
error('matfaust.factparams.ParamsFact 1st argument (num_facts) must be an integer.')
error('matfaust.factparams.ParamsFact num_facts argument must be an integer.')
else
num_facts = floor(num_facts);
end
if(~ islogical(is_update_way_R2L))
error('matfaust.factparams.ParamsFact 2nd argument (is_update_way_R2L) must be logical.')
end
if(~ isscalar(init_lambda))
error('matfaust.factparams.ParamsFact 3rd argument (init_lambda) must be a scalar.')
end
if(~ iscell(constraints))
error('matfaust.factparams.ParamsFact 4th argument (constraints) must be a cell array.')
error(['matfaust.factparams.ParamsFact constraints argument must be a cell array.'])
end
for i = 1:length(constraints) %TODO: check constraints length in sub-class
for i = 1:length(constraints) %ParamsFact.TODO: check constraints length in sub-class
if(~ isa(constraints{i}, 'matfaust.factparams.ConstraintGeneric'))
error('matfaust.factparams.ParamsFact 5th argument (constraints) must contain matfaust.factparams.ConstraintGeneric objects.')
error(['matfaust.factparams.ParamsFact constraints argument must contain matfaust.factparams.ConstraintGeneric objects.'])
end
end
if(nargin > MIN_NARGIN)
step_size = varargin{MIN_NARGIN+1};
if(nargin > MIN_NARGIN+1)
constant_step_size = varargin{MIN_NARGIN+2};
if(nargin > MIN_NARGIN+2)
is_verbose = varargin{MIN_NARGIN+3};
end
end
% try to get optional arguments
% construct a map of optional arguments from varargin
% NOTE: it avoids a if imbrication of depth the number length(varargin)
% NOTE: we can change the order of arguments in properties (ParamsFact.IDX), the code will stay valid
opt_arg_map = containers.Map();
ParamsFact.parse_opt_args(varargin, ParamsFact.OPT_ARG_NAMES, opt_arg_map)
% now get values of opt args really passed
% TODO: a function to hide the complexity returning the value arg or the default value if not set in map
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_IS_UPDATE_WAY_R2L}))
is_update_way_R2L = opt_arg_map(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_IS_UPDATE_WAY_R2L});
end
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_INIT_LAMBDA}))
init_lambda = opt_arg_map(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_INIT_LAMBDA});
end
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_STEP_SIZE}))
step_size = opt_arg_map(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_STEP_SIZE});
end
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_CONSTANT_STEP_SIZE}))
constant_step_size = opt_arg_map(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_CONSTANT_STEP_SIZE});
end
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_VERBOSITY}))
is_verbose = opt_arg_map(ParamsFact.OPT_ARG_NAMES{ParamsFact.IDX_VERBOSITY});
end
% then check validity of opt args (it's useless for default values but it's not too costfull)
if(~ islogical(is_update_way_R2L))
error('matfaust.factparams.ParamsFact ', p.OPT_ARG_NAMES{ParamsFact.IDX_IS_UPDATE_WAY_R2L} ,' argument (is_update_way_R2L) must be logical.')
end
if(~ isscalar(init_lambda))
error('matfaust.factparams.ParamsFact ', p.OPT_ARG_NAMES{ParamsFact.IDX_INIT_LAMBDA},' argument (init_lambda) must be a scalar.')
end
if(~ isscalar(step_size))
step_size
error(['matfaust.factparams.ParamsHierarchicalFact ', int2str(MIN_NARGIN+1), 'th argument (step_size) must be a real.'])
error(['matfaust.factparams.ParamsFact ', p.OPT_ARG_NAMES{ParamsFact.IDX_STEP_SIZE}, ' argument (step_size) must be a real.'])
end
if(~ islogical(constant_step_size))
error(['matfaust.factparams.ParamsFact ', int2str(MIN_NARGIN+2), 'th argument (constant_step_size) must be logical.'])
error(['matfaust.factparams.ParamsFact ', p.OPT_ARG_NAMES{ParamsFact.IDX_CONSTANT_STEP_SIZE}, ' argument (constant_step_size) must be logical.'])
end
if(~ islogical(is_verbose))
error(['matfaust.factparams.ParamsFact ',int2str(MIN_NARGIN+3),' argument (is_verbose) must be logical.'])
error(['matfaust.factparams.ParamsFact ', p.OPT_ARG_NAMES{ParamsFact.IDX_VERBOSITY},' argument (is_verbose) must be logical.'])
end
p.num_facts = num_facts;
p.is_update_way_R2L = is_update_way_R2L;
......@@ -86,5 +107,40 @@ classdef (Abstract) ParamsFact
bool = s(1) == this.constraints{1}.num_rows && s(2) == this.constraints{end}.num_cols;
end
end
end
methods(Static)
function parse_opt_args(cell_args, opt_arg_names, opt_arg_map)
if(~ iscell(cell_args))
error('cell_args must be a cell array')
end
nopt_args = length(cell_args);
if(nopt_args > 0)
i=1;
while(i<=nopt_args)
i_arg_matched = false;
if(~ isstr(cell_args{i}))
unrecognized_argument = cell_args{i};
error('above value is not a keyword argument. It must be a char array.')
end
for j=1:length(opt_arg_names)
if(strcmp(cell_args{i},opt_arg_names{j}))
i_arg_matched = true;
if(length(cell_args) >= i)
opt_arg_map(opt_arg_names{j}) = cell_args{i+1};
else
error([ 'the keyword argument ' opt_arg_names{j} ' must be followed by a value argument'])
end
end
end
if(~ i_arg_matched)
unrecognized_argument = cell_args{i}
error(['Value above is an unrecognized keyword argument.'])
end
i = i + 2;
end
end
end
end
end
......@@ -9,54 +9,56 @@ classdef ParamsHierarchicalFact < matfaust.factparams.ParamsFact
end
properties(Constant)
DEFAULT_IS_FACT_SIDE_LEFT = false
IDX_IS_FACT_SIDE_LEFT = 1
OPT_ARG_NAMES2 = { 'is_fact_side_left' }
end
methods
function p = ParamsHierarchicalFact(varargin)
MIN_NARGIN = 6;
if(nargin < MIN_NARGIN)
error(['matfaust.factparams.ParamsHierarchicalFact() must receive at least',int2str(MIN_NARGIN),' arguments'])
function p = ParamsHierarchicalFact(fact_constraints, res_constraints, stop_crit1, stop_crit2, varargin)
import matfaust.factparams.*
if(~ iscell(fact_constraints))
error('fact_constraints (argument 1) must be a cell array')
end
if(~ iscell(res_constraints))
error('res_constraints (argument 2) must be a cell array')
end
if(length(fact_constraints) ~= length(res_constraints))
error('lengths of fact_constraints and res_constraints must be equal.')
end
if(~ isa(stop_crit1, 'StoppingCriterion'))
error('stop_crit1 (argument 3) must a StoppingCriterion')
end
if(~ isa(stop_crit2, 'StoppingCriterion'))
error('stop_crit2 (argument 4) must a StoppingCriterion')
end
num_facts = varargin{1};
is_update_way_R2L = varargin{2};
init_lambda = varargin{3};
fact_constraints = varargin{4};
res_constraints = varargin{5};
constraints = {fact_constraints{:}, res_constraints{:}};
% data_num_rows/data_num_cols are set by FaustFactory.fact_hierarchical()
stop_crits = varargin{6};
% set default values
is_fact_side_left = matfaust.factparams.ParamsHierarchicalFact.DEFAULT_IS_FACT_SIDE_LEFT;
step_size = matfaust.factparams.ParamsFact.DEFAULT_STEP_SIZE;
is_verbose = matfaust.factparams.ParamsFact.DEFAULT_VERBOSITY;
constant_step_size = matfaust.factparams.ParamsFact.DEFAULT_CONSTANT_STEP_SIZE;
if(nargin > MIN_NARGIN+1)
step_size = varargin{MIN_NARGIN+2};
if(nargin > MIN_NARGIN+2)
constant_step_size = varargin{MIN_NARGIN+3};
if(nargin > MIN_NARGIN+3)
is_verbose = varargin{MIN_NARGIN+4};
if(nargin > MIN_NARGIN+4)
is_fact_side_left = varargin{MIN_NARGIN+5};
end
stop_crits = {stop_crit1, stop_crit2};
% infer number of factors from constraints
num_facts = length(fact_constraints)+1;
parent_args = {};
opt_arg_map = containers.Map();
if(length(varargin) > 0)
% retrieve all optional argument key-value pairs
opt_arg_names = {ParamsFact.OPT_ARG_NAMES, ParamsHierarchicalFact.OPT_ARG_NAMES2};
opt_arg_names = {opt_arg_names{1}{:}, opt_arg_names{2}{:}};
ParamsFact.parse_opt_args(varargin, opt_arg_names, opt_arg_map)
% gather all parent argument key-value pairs
for i=1:length(ParamsFact.OPT_ARG_NAMES)
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{i}))
parent_args = [ parent_args, {ParamsFact.OPT_ARG_NAMES{i}}, {opt_arg_map(ParamsFact.OPT_ARG_NAMES{i}) }];
end
end
% parent constructor handles verification for its own arguments
end
% parent constructor handles verification for its own arguments
p = p@matfaust.factparams.ParamsFact(num_facts, is_update_way_R2L, init_lambda, ...
constraints, step_size, constant_step_size, is_verbose);
if(~ iscell(stop_crits))
error('matfaust.factparams.ParamsHierarchicalFact 6th argument (stop_crits) must be a cell array.')
if(length(stop_crits) ~= 2 )
error('matfaust.factparams.ParamsHierarchicalFact 6th argument (stop_crits) must be a cell array of 2 elements.')
end
for i = 1:length(stop_crits)
if(~ isa(stop_crits{i}, matfaust.factparams.StoppingCriterion))
error('matfaust.factparams.ParamsHierarchicalFact 6th argument (stop_crits) must contain matfaust.factparams.StoppingCriterion objects.')
end
end
p = p@matfaust.factparams.ParamsFact(num_facts, constraints, parent_args{:});
% data_num_rows/data_num_cols are set by FaustFactory.fact_hierarchical()
% set default values
is_fact_side_left = ParamsHierarchicalFact.DEFAULT_IS_FACT_SIDE_LEFT;
if(opt_arg_map.isKey(ParamsHierarchicalFact.OPT_ARG_NAMES2{p.IDX_IS_FACT_SIDE_LEFT}))
is_fact_side_left = opt_arg_map(ParamsHierarchicalFact.OPT_ARG_NAMES2{p.IDX_IS_FACT_SIDE_LEFT});
end
if(~ islogical(is_fact_side_left))
error('matfaust.factparams.ParamsHierarchicalFact 11th argument (is_fact_side_left) must be logical.')
error('matfaust.factparams.ParamsHierarchicalFact: is_fact_side_left argument must be logical.')
end
p.stop_crits = stop_crits;
p.is_fact_side_left = is_fact_side_left;
......
%% class ParamsPalm4MSA
%%
%
classdef ParamsPalm4MSA < matfaust.factparams.ParamsFact
properties (SetAccess = public)
init_facts
stop_crit
end
properties (Constant, SetAccess = private)
IDX_INIT_FACTS = 1
OPT_ARG_NAMES2 = { 'init_facts' }
end
methods
function p = ParamsPalm4MSA(varargin)
import matfaust.factparams.ParamsFact
MIN_NARGIN = 5;
if(nargin < MIN_NARGIN)
error(['matfaust.factparams.ParamsPalm4MSA() must receive at least ', int2str(MIN_NARGIN),' arguments.'])
function p = ParamsPalm4MSA(constraints, stop_crit, varargin)
import matfaust.factparams.*
if(~ iscell(constraints))
error('constraints (argument 1) must be a cell array')
end
num_facts = varargin{1};
is_update_way_R2L = varargin{2};
init_lambda = varargin{3};
constraints = varargin{4};
stop_crit = varargin{5};
% set default values
step_size = ParamsFact.DEFAULT_STEP_SIZE;
is_verbose = ParamsFact.DEFAULT_VERBOSITY;
constant_step_size = ParamsFact.DEFAULT_CONSTANT_STEP_SIZE;
is_init_facts_to_default = nargin <= MIN_NARGIN;
if(~ is_init_facts_to_default)
init_facts = varargin{MIN_NARGIN+1};
if(nargin > MIN_NARGIN+1)
step_size = varargin{MIN_NARGIN+2};
if(nargin > MIN_NARGIN+2)
constant_step_size = varargin{MIN_NARGIN+3};
if(nargin > MIN_NARGIN+3)
is_verbose = varargin{MIN_NARGIN+4};
end
end
end
num_facts = length(constraints);
if(~ isa(stop_crit, 'StoppingCriterion'))
error('stop_crit (argument 2) must a StoppingCriterion')
end
% parent constructor handles verification for its own arguments
p = p@matfaust.factparams.ParamsFact(num_facts, is_update_way_R2L, init_lambda, ...
constraints, step_size, constant_step_size, is_verbose);
if(is_init_facts_to_default || iscell(init_facts) && length(init_facts) == 0)
init_facts = cell(num_facts, 1);
if(is_update_way_R2L)
zeros_id = num_facts;
else
zeros_id = 1;
end
for i=1:num_facts
if(i ~= zeros_id)
init_facts{i} = eye(constraints{i}.num_rows, constraints{i}.num_cols);
parent_args = {};
opt_arg_map = containers.Map();
if(length(varargin) > 0)
% retrieve all optional argument key-value pairs
opt_arg_names = {ParamsFact.OPT_ARG_NAMES, ParamsPalm4MSA.OPT_ARG_NAMES2};
opt_arg_names = {opt_arg_names{1}{:}, opt_arg_names{2}{:}};
ParamsFact.parse_opt_args(varargin, opt_arg_names, opt_arg_map)
% gather all parent argument key-value pairs
for i=1:length(ParamsFact.OPT_ARG_NAMES)
if(opt_arg_map.isKey(ParamsFact.OPT_ARG_NAMES{i}))
parent_args = [ parent_args, {ParamsFact.OPT_ARG_NAMES{i}}, {opt_arg_map(ParamsFact.OPT_ARG_NAMES{i}) }];
end
end
init_facts{zeros_id} = ...
zeros(constraints{zeros_id}.num_rows, constraints{zeros_id}.num_cols);
end%
% parent constructor handles verification for its own arguments
end
p = p@matfaust.factparams.ParamsFact(num_facts, constraints, parent_args{:});
init_facts_name = p.OPT_ARG_NAMES{p.IDX_INIT_FACTS};
try
init_facts = opt_arg_map(init_facts_name);
catch
% arg int_facts not passed
end
if(~ exist(init_facts_name) || iscell(init_facts) && length(init_facts) == 0)
init_facts = p.get_default_init_facts(num_facts);
elseif(~ iscell(init_facts)) % TODO: check init_facts length
error('matfaust.factparams.ParamsFactPalm4MSA 4th argument (init_facts) must be a cell array.')
error(['matfaust.factparams.ParamsFactPalm4MSA argument ' init_facts_name ' must be a cell array.'])
else
% check init_facts
% TODO: check the number of init_facts
for i = 1:length(init_facts)
if(~ ismatrix(init_facts{i}) || ~ isnumeric(init_facts{i}))
error('matfaust.factparams.ParamsFactPalm4MSA 4th argument (init_facts) must contain matrices.')
%TODO: check matrix dimensions
error(['matfaust.factparams.ParamsFactPalm4MSA ' init_facts_name ' argument must contain matrices.'])
% matrix dimensions are tested later by fact_palm4msa() with is_mat_consistent()
% TODO: add to is_mat_consistent() the checking of init_facts
end
end
end
......@@ -69,4 +65,21 @@ classdef ParamsPalm4MSA < matfaust.factparams.ParamsFact
p.stop_crit = stop_crit;
end
end
methods
function init_facts = get_default_init_facts(p, num_facts)
init_facts = cell(num_facts, 1);
if(p.is_update_way_R2L)
zeros_id = num_facts;
else
zeros_id = 1;
end
for i=1:num_facts
if(i ~= zeros_id)
init_facts{i} = eye(p.constraints{i}.num_rows, p.constraints{i}.num_cols);
end
end
init_facts{zeros_id} = ...
zeros(p.constraints{zeros_id}.num_rows, p.constraints{zeros_id}.num_cols);
end
end
end
......@@ -65,15 +65,10 @@ classdef FaustFactory
%> @code
%> import matfaust.*
%> import matfaust.factparams.*
%> num_facts = 2;
%> is_update_way_R2L = false;
%> init_lambda = 1.0;
%> M = rand(500, 32);
%> cons = cell(2,1);
%> cons{1} = ConstraintInt('splin', 500, 32, 5);
%> cons{2} = ConstraintReal('normcol', 32, 32, 1.0);
%> cons = {ConstraintInt('splin', 500, 32, 5), ConstraintReal('normcol', 32, 32, 1.0)};
%> stop_crit = StoppingCriterion(200);
%> params = ParamsPalm4MSA(num_facts, is_update_way_R2L, init_lambda, cons, stop_crit);
%> params = ParamsPalm4MSA(cons, stop_crit, 'is_update_way_R2L', false, 'init_lambda', 1.0);
%> F = FaustFactory.fact_palm4msa(M, params)
%> @endcode
%>
......@@ -126,21 +121,14 @@ classdef FaustFactory
%> @code
%> import matfaust.*
%> import matfaust.factparams.*
%> num_facts = 4;
%> is_update_way_R2L = false;
%> init_lambda = 1.0;
%> M = rand(500, 32);
%> fact_cons = cell(3, 1);
%> res_cons = cell(3, 1);
%> fact_cons{1} = ConstraintInt('splin', 500, 32, 5);
%> fact_cons{2} = ConstraintInt('sp', 32, 32, 96);
%> fact_cons{3} = ConstraintInt('sp', 32, 32, 96);
%> res_cons{1} = ConstraintReal('normcol', 32, 32, 1);
%> res_cons{2} = ConstraintInt('sp', 32, 32, 666);
%> res_cons{3} = ConstraintInt('sp', 32, 32, 333);
%> fact_cons = {ConstraintInt('splin', 500, 32, 5), ConstraintInt('sp', 32, 32, 96), ConstraintInt('sp', 32, 32, 96)};
%> res_cons = {ConstraintReal('normcol', 32, 32, 1), ConstraintInt('sp', 32, 32, 666), ConstraintInt('sp', 32, 32, 333)};
%> stop_crit = StoppingCriterion(200);
%> stop_crit2 = StoppingCriterion(200);
%> params = ParamsHierarchicalFact(num_facts, is_update_way_R2L, init_lambda, fact_cons, res_cons, {stop_crit, stop_crit2});
%> params = ParamsHierarchicalFact(fact_cons, res_cons, stop_crit, stop_crit2, 'is_update_way_R2L', false, 'init_lambda', 1.0);
%> F = FaustFactory.fact_hierarchical(M, params)
%> @endcode
%> Faust::HierarchicalFact<FPP,DEVICE>::compute_facts : factorisation 1/3<br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment