Commit 7f1395e9 authored by Carlos Mejia's avatar Carlos Mejia
Browse files

Example code as a simple main front of 2S-SOM code

parents
function [bmus, ddist] = compute_bmusRTOM(D, sMap, Alpha, Beta )
% Function to compute BMU for a Data set into a SOM or 2S-SOM trained sMap.
%
% Usage:
% Bmus = compute_bmusRTOM(Data, sMap, Alpha, Beta);
%
% Bmus = compute_bmus_poids(StD_mdl.SomData, StOut.sMap, StOut.Alpha, StOut.Beta);
%
% [Bmus, Dist] = compute_bmusRTOM(StD_mdl.SomData, StOut.sMap, StOut.Alpha, StOut.Beta);
%
% Historical:
% Function created by Sirine Sandid et Narjes Karmani during the "Projet
% Long" of their TRIED Master 2 year, in March 2019. They had worked based
% on the 2S-SOM som_batchtrainRTOM.m training function. The original name
% of the function was compute_bmus_poids.
%
% Code simplification and litle optimisation C.Mejia - Locean
% Cleaning innecessary code 02/05/2019
% Directly passing Alpha et Beta arguments (in place of StOut)
% Renaming the function to compute_bmusRTOM
%
narginchk(4, Inf); % check the number of input arguments
% map
%disp(sMap.codebook)
if ~isstruct(sMap)
error('first argument: ''sMap'', is not a struct!');
end
if ~isempty(Beta) && ~isstruct(Beta)
error('fourth argument: ''Beta'', is not a struct!');
end
if isempty(Alpha) && isempty(Beta)
fprintf(1,' ** Empty ALPHA and BETA coeficient arrays, using then SOM_BMUS ...\n')
[bmus,Qerrors] = som_bmus(sMap, D);
ddists = [];
else
%RT initialisation de updateRule
UpdateRule='numeric'; %valeur par defaut
% initialise DimData in function of Beta blocks dimensions
DimData = zeros(size(Beta));
nblocks = length(Beta);
for iBloc = 1:nblocks
DimData(iBloc) = size(Beta(iBloc).Beta_ck,2);
end
% data
if isstruct(D)
data_name = D.name;
D = D.data;
else
%data_name = inputname(2);
data_name = 'data';
end
[munits, unitsdim] = size(sMap.codebook);
nonempty = find(sum(isnan(D),2) < unitsdim);
D = D(nonempty,:); % remove from the data vectors having NaNs
[npatterns, patternsize] = size(D); % check input data dimensions
if unitsdim ~= patternsize
error('Map and data input space dimensions disagree.');
end
%arrayok = all(arrayfun(@(d) ~isscalar(d),DimData))
for di=1:length(DimData)
DimBloc(di).Dim = DimData(di);
end
%%
M = sMap.codebook;
mask = sMap.mask;
for di=1:nblocks
DimBloc(di).Dim = DimData(di);
end
Dist = zeros(munits, npatterns);
%if arrayok
% initializing DB block struct
deb = 1; BD = struct; % structure contenant les blocs de donnees
for iBloc = 1:nblocks % iteration sur les blocs de variables
fin=sum(DimData(1:iBloc));
%fprintf(1,'--Iter_i(%d): deb=%d, fin=%d\n', iBloc,deb,fin);
BD(iBloc).D = D(:,deb:fin);
BD(iBloc).M = M(:,deb:fin);
BD(iBloc).Dim = DimBloc(iBloc).Dim;
BD(iBloc).mask = mask(deb:fin);
BD(iBloc).Known = ~isnan(BD(iBloc).D);
% ----------------------------
debBloc = 1;
for k = 1:length(BD(iBloc).Dim) % Creation des blocs de variables selon les blocs dans Beta (a priori un seul!)
finBloc = sum(BD(iBloc).Dim(1:k)); %ok
%fprintf(1,' --Iter_k(%d): debB=%d, finB=%d\n', k,debBloc,finBloc);
% -----------------------------------------------------------------
BD(iBloc).SBD(k).D = BD(iBloc).D(:,debBloc:finBloc); %ok
BD(iBloc).SBD(k).Known = ~isnan(BD(iBloc).SBD(k).D); % ok
BD(iBloc).SBD(k).D(~BD(iBloc).SBD(k).Known) = 0; % ok
BD(iBloc).SBD(k).M = BD(iBloc).M(:,debBloc:finBloc); % ok
BD(iBloc).SBD(k).mask = BD(iBloc).mask(debBloc:finBloc); % ok
BD(iBloc).SBD(k).W1 = (BD(iBloc).SBD(k).mask * ones(1,npatterns)) .* BD(iBloc).SBD(k).Known'; % ok
BD(iBloc).SBD(k).WD = 2 * diag(BD(iBloc).SBD(k).mask) * BD(iBloc).SBD(k).D'; % ok
%BD(iBloc).SBD(k).dconst = ((BD(iBloc).SBD(k).D .^ 2) * BD(iBloc).SBD(k).mask)'; % ok
BD(iBloc).SBD(k).W2 = ones(munits,1) * BD(iBloc).SBD(k).mask';
BD(iBloc).SBD(k).D2 = BD(iBloc).SBD(k).D' .^ 2;
% -----------------------------------------------------------------
debBloc = finBloc+1;
end
deb = fin + 1;
BetaAlpaTmp = Beta(iBloc).Beta_ck .* Alpha(:,iBloc);
if strcmp(UpdateRule,'numeric')
for k = 1:length(BD(iBloc).Dim) % pour chaque bloc de variables dans Beta (a priori un seul!)
Dist = Dist + ( (BetaAlpaTmp .* (BD(iBloc).SBD(k).M .^ 2)) * BD(iBloc).SBD(k).W1 - ...
(BetaAlpaTmp .* BD(iBloc).SBD(k).M ) * BD(iBloc).SBD(k).WD + ...
(BetaAlpaTmp .* BD(iBloc).SBD(k).W2 ) * BD(iBloc).SBD(k).D2 ) / ...
BD(iBloc).Dim(k);
end
end
end
%else
%end
[ddists, bmus] = min(Dist);
end
if nargout > 1
ddist = Dist;
end
end
function Dist = distance_RTOM(D, M, Mask, Alpha, Beta )
% Function to compute the distance between D patterns and M matterns
% weighted by Alpha and Beta coeficients.
%
% Usage:
% Dist = distance_RTOM(D, M, Alpha, Beta);
%%
% Historical:
% Computes distance between Data1 and Data2 patterns. Each line in D and
% M is a pattern. Inspired in som_batchtrainRTOM.m.
%
% Function creation C.Mejia - Locean
% 12/05/2019
%
narginchk(4, Inf); % check the number of input arguments
verbose_ok = true;
if ~isempty(Beta) && ~isstruct(Beta)
error('fourth argument: ''Beta'', is not a struct!');
end
if isempty(Alpha) && isempty(Beta)
fprintf(1,' ** Empty ALPHA and BETA coeficient arrays, using a classic distance NOT CODED YET ! ...\n')
Dist = [];
return
else
% initialise DimData in function of Beta blocks dimensions
DimData = zeros(size(Beta));
nblocks = length(Beta);
for iBloc = 1:nblocks
DimData(iBloc) = size(Beta(iBloc).Beta_ck,2);
end
% data
[munits, unitsdim] = size(M);
nonempty = find(sum(isnan(D),2) < unitsdim);
D = D(nonempty,:); % remove from the data vectors having NaNs
[npatterns, patternsize] = size(D); % check input data dimensions
if unitsdim ~= patternsize
error('Map and data input space dimensions disagree.');
end
%%
if isempty(Mask)
Mask = ones(unitsdim,1);
end
vDeb(1) = 1;
for di=1:nblocks
vFin(di) = sum(DimData(1:di));
if di < nblocks
vDeb(di + 1) = vFin(di) + 1;
end
DimBloc(di).Dim = DimData(di);
end
TDist = zeros(munits, npatterns, nblocks);
% if BETA blocks has sub-blocks! (BETA block comes from ALPHA blocks)
subArrayOk = all(arrayfun(@(d) ~isscalar(d),DimData));
tic
if subArrayOk % || true
if verbose_ok, disp('--subArrayOk ...'), end
% initializing DB block struct
deb = 1; BD = struct; % structure contenant les blocs de donnees
for iBloc = 1:nblocks % iteration sur les blocs de variables
fin=sum(DimData(1:iBloc));
%fprintf(1,'--Iter_i(%d): deb=%d, fin=%d\n', iBloc,deb,fin);
BD(iBloc).D = D(:,deb:fin);
BD(iBloc).M = M(:,deb:fin);
BD(iBloc).Dim = DimBloc(iBloc).Dim;
BD(iBloc).mask = Mask(deb:fin);
BD(iBloc).Known = ~isnan(BD(iBloc).D);
% ----------------------------
debBloc = 1;
for k = 1:length(BD(iBloc).Dim) % Creation des blocs de variables selon les blocs dans Beta (a priori un seul!)
finBloc = sum(BD(iBloc).Dim(1:k)); %ok
%fprintf(1,' --Iter_k(%d): debB=%d, finB=%d\n', k,debBloc,finBloc);
% -----------------------------------------------------------------
BD(iBloc).SBD(k).D = BD(iBloc).D(:,debBloc:finBloc); %ok
BD(iBloc).SBD(k).Known = ~isnan(BD(iBloc).SBD(k).D); % ok
BD(iBloc).SBD(k).D(~BD(iBloc).SBD(k).Known) = 0; % ok
BD(iBloc).SBD(k).M = BD(iBloc).M(:,debBloc:finBloc); % ok
BD(iBloc).SBD(k).mask = BD(iBloc).mask(debBloc:finBloc); % ok
BD(iBloc).SBD(k).W1 = (BD(iBloc).SBD(k).mask * ones(1,npatterns)) .* BD(iBloc).SBD(k).Known'; % ok
BD(iBloc).SBD(k).WD = 2 * diag(BD(iBloc).SBD(k).mask) * BD(iBloc).SBD(k).D'; % ok
%BD(iBloc).SBD(k).dconst = ((BD(iBloc).SBD(k).D .^ 2) * BD(iBloc).SBD(k).mask)'; % ok
BD(iBloc).SBD(k).W2 = ones(munits,1) * BD(iBloc).SBD(k).mask';
BD(iBloc).SBD(k).D2 = BD(iBloc).SBD(k).D' .^ 2;
% -----------------------------------------------------------------
debBloc = finBloc+1;
end
deb = fin + 1;
BetaAlpaTmp = Beta(iBloc).Beta_ck .* Alpha(:,iBloc);
for k = 1:length(BD(iBloc).Dim) % pour chaque bloc de variables dans Beta (a priori un seul!)
TDist(:,:,iBloc) = TDist(:,:,iBloc) + ( (BetaAlpaTmp .* (BD(iBloc).SBD(k).M .^ 2)) * BD(iBloc).SBD(k).W1 - ...
(BetaAlpaTmp .* BD(iBloc).SBD(k).M ) * BD(iBloc).SBD(k).WD + ...
(BetaAlpaTmp .* BD(iBloc).SBD(k).W2 ) * BD(iBloc).SBD(k).D2 ) / ...
BD(iBloc).Dim(k);
end
end
elseif any(isnan(D(:))) || ~all(Mask(:)) % || true
if verbose_ok, disp('--subArray NOk but NaN or Mask ...'), end
% S'il y a un NaN dans D ou un codebook masque (=0) dans M
% initializing DB block struct
deb = 1; BD = struct; % structure contenant les blocs de donnees
for iBloc = 1:nblocks % iteration sur les blocs de variables
fin=sum(DimData(1:iBloc));
%fprintf(1,'--Iter_i(%d): deb=%d, fin=%d\n', iBloc,deb,fin);
BD(iBloc).D = D(:,deb:fin);
BD(iBloc).M = M(:,deb:fin);
BD(iBloc).Dim = DimBloc(iBloc).Dim;
BD(iBloc).mask = Mask(deb:fin);
BD(iBloc).Known = ~isnan(BD(iBloc).D);
BD(iBloc).D(~BD(iBloc).Known) = 0; % ok
% -----------------------------------------------------------------
BD(iBloc).W1 = (BD(iBloc).mask * ones(1,npatterns)) .* BD(iBloc).Known'; % ok
BD(iBloc).WD = 2 * diag(BD(iBloc).mask) * BD(iBloc).D'; % ok
%BD(iBloc).dconst = ((BD(iBloc).D .^ 2) * BD(iBloc).mask)'; % ok
BD(iBloc).W2 = ones(munits,1) * BD(iBloc).mask';
BD(iBloc).D2 = BD(iBloc).D' .^ 2;
deb = fin + 1;
BetaAlpaTmp = Beta(iBloc).Beta_ck .* Alpha(:,iBloc);
TDist(:,:,iBloc) = ( (BetaAlpaTmp .* (BD(iBloc).M .^ 2)) * BD(iBloc).W1 - ...
(BetaAlpaTmp .* BD(iBloc).M ) * BD(iBloc).WD + ...
(BetaAlpaTmp .* BD(iBloc).W2 ) * BD(iBloc).D2 ) / ...
BD(iBloc).Dim;
end
else
%if verbose_ok, ticBytes(gcp); end % POUR CALCUL PARALLELE
if verbose_ok, disp('--simplified ...'), end
% Si aucun NaN dans D et pas de codebook masqu (tous =1 dans M)
% ALORS on simplifie ...
%parfor iBloc = 1:nblocks % iteration sur les blocs de variables - POUR CALCUL PARALLELE
for iBloc = 1:nblocks % iteration sur les blocs de variables
deb = vDeb(iBloc);
fin = vFin(iBloc);
%fprintf(1,'--Iter_i(%d): deb=%d, fin=%d\n', iBloc,deb,fin);
TD = D(:,deb:fin)'; % transpose
TM = M(:,deb:fin);
TmpDim = DimBloc(iBloc).Dim;
% -----------------------------------------------------------------
BetaAlpaTmp = Beta(iBloc).Beta_ck .* repmat(Alpha(:,iBloc),1,TmpDim);
TDist(:,:,iBloc) = ( repmat((BetaAlpaTmp .* (TM .^ 2)) * ones(TmpDim,1),1,npatterns) - ...
2 * (BetaAlpaTmp .* TM) * TD + ...
BetaAlpaTmp * (TD .^ 2) ) / ...
TmpDim;
end
%if verbose_ok, tocBytes(gcp), end % POUR CALCUL PARALLELE
end
Dist = sum(TDist,3);
elapsedtime = toc;
if verbose_ok,
fprintf(1,'-- %s computing time: %.2fms\n',mfilename,1000*elapsedtime);
end
end
end
File added
% SCRIPT_RUNNING_2S_SOM
%
% Sample code for preparing to use 2S-SOM algorithm.
%
% The problem:
% -----------
% Using a three-physical-variables two-groups problem to be trained using the 2S-SOM
% algorithm. We are only interested here, for instance, in the group coefficients
% ALPHA, and we let the variables or columns coefficients, BETA, constant and
% equal. This will be driven by a particular use of Lambda and Eta input
% parameters. See code.
%
% Data array dimension is 36 x N. 36 is the composition of thee geophysical
% variable dimensions of (12, 12, 12) and N the number of patterns.
%
% We take the first 12 columns, for the first 2S-SOM group and the rest, 24 columns,
% for the second group.
%
%
% About the problem from a geophysical point of view:
% --------------------------------------------------
% We have the Sea Surface Temperature (SST) data in a region over the Atlantic
% ocean, in front the Senegal and Mauritanian coasts and also the wind speed given in
% the Eastward and Northward components, named U end V and measured at 10 meters
% (i.e. U10 and V10).
%
% This geographical zone is well known by the presence of a strong upwelling phenomena
% in ocean waters near the coast. This phenomena is characterized by a cooler water
% measured in the coast and this temperature variation comes when surface waters near
% the coast are pushed seaward by a strength resulting from the Coriolis acceleration
% in interaction with the wind.
%
% Due to the Coriolis accelerations, a wind going from North to South in a coastal
% border oriented North-South produce a strength pushing the water Westward,
% i.e. seaward. This give place to new water and will be filled by fresh water
% coming from deeper ocean.
%
% Upwelling in this region is a periodical phenomena and is present only in a
% particular period of the year, roughly in the winter period.
%
% Data is given monthly and we will take only a year of data. Each pixel in the
% region will represent a line of data in the SOM/2S-SOM data array. Thus, for each
% pixel we should compose a vector of 12 months for each geophysical variable (SST,
% U10, V10). From the point of view of SOM, we have thus an input matrix of
% dimensions 36xN, where N are the number valid pixels in the region.
%
% For this particular problem and for a better characterization of the upwelling
% phenomena, we decide to use the SST anomaly rather than the real SST. The anomaly
% is the monthly difference with respect to a yearly average. We denote this variable
% as ASST.
%
% We have thus an array of 36 columns representing three geophysical variables and
% we will range them in two 2S-SOM groups:
%
% - first 2S-SOM group: ASST
% - second 2S-SOM group: U10 and V10
%
%
% About 2S-SOM training parameters LAMBDA and ETA:
% -----------------------------------------------
% Each LAMBDA and Eta parameters could be one scalar value or a list of values.
% The idea is to train multiple times varying LAMBDA in order to have the least SOM
% distortion error (called PERF in the RESULT vector struct returned by
% LEARN_2S_SOM). A complete SOM/2S-SOM training is realized for each couple of
% values {lambda(i),eta(j)}. LAMBDA parameter value is responsible of the ALPHA
% group coefficient, and ETA from BETA variable intra group coefficient.
%
%
% Software needed :
% ----------------
%
% For 2S-SOM get the software at git page:
% https://github.com/carmman/2S-SOM_versionCM
%
% You should use learn_2s_som.m funtion found in Code-2S-SOM/ and functions in
% Code-2S-SOM/2s_som/ subdirectories.
%
% Also, some functions having the same name as original SOM Toolbox functions as
% som_batchtrain.m, som_make.m and som_randinit.m, found it in
% Code-2S-SOM/som_for_2s_som/ subdir.
%
% You need the SOM Toolbox. See ilarinieminen git page at
% https://github.com/ilarinieminen/SOM-Toolbox
%
% you will need the functions in "som/" subdirectory.
%
% See ADDPATH examples in this script code for knowing the order of how to declare it.
%
%
% History:
% -------
% Main developpement of 2S-SOM Matlab functions was made by Khalil Yala at Locean
% Laboratory et Sorbonne Universites and adapted and put in GitHub by C.Mejia
% IPSL/Locean same institution who writes also this script ........... 19/07/2019
%
%% ----------------------------------------------------------------------------------
% adding paths ...
% ----------------------------------------------------------------------------------
% where the 2S-SOM funtions are:
code_base_path = '~/Labo/NN_divers/Devel/2S-SOM/Code-2S-SOM';
% where SOM Toolbox funtions are:
if ~exist('som_make','file') % SOM Toolbox functions ...
if ~exist('som_data_struct','file')
% where the proper SOM Toolbox functions are !
addpath('~/Labo/libmatlab/SOMtoolboxV21/SOM-Toolbox/som')
% SEE ilarinieminen git page at https://github.com/ilarinieminen/SOM-Toolbox
end
% SOM Toolbox modified functions for 2S-SOM (having the same name) ...
addpath([ code_base_path filesep 'som_for_2s_som' ])
end
% 2S-SOM low lever functions
if ~exist('som_batchtrainRTOM','file') % Fonctions propres a 2S-SOM ...
addpath([ code_base_path filesep '2s_som' ])
end
% 2S-SOM high level functions (the one we call here: learn_2s_som)
if ~exist('learn_2s_som','file') % Fonction ppal pour 2S-SOM ...
addpath(code_base_path)
end
% ----------------------------------------------------------------------------------
%% ----------------------------------------------------------------------------------
% Reading data
% ----------------------------------------------------------------------------------
% Here, is data composed of four variables:
% - NORMDATA, 743 x 36 already normalized data. Each line of 36 values is a pixel
% data composed of 12 values of ASST, 12 of U10 and 12 for V10. All
% normalized. Here, normalization was a simple division by a Max value, we
% dont't center data in special to keep the significance of the wind vector wos
% components are U10 and V10.
% - IOCEANMASK: index of the 2D grid where the current pixel really is.
% - LON and LAT: Longitude and Latitude of the 2D grid of data.
% ----------------------------------------------------------------------------------
load input_data.mat % Reads variables normalized data: normdata, lon, lat, ioceanmask
% --------------------------------------------------------------------------------
%% ----------------------------------------------------------------------------------
% Example of building 2D var and plotting, just for verification: ------------------
it=8; % <-- choose another it to see ...
nASSTslice = normdata(:,it); % a ASST slice (eighth column, or month, for instance)
% Buiding a 2D version of the SST anomaly for plotting (for verification)
nASSTarr = nan(length(lon),length(lat));
nASSTarr(ioceanmask) = nASSTslice;
%
figure
imagesc(lon,lat,nASSTarr')
axis xy
colorbar
title(sprintf('Example of SST anomaly [month=%d] (normalized)',it))
xlabel('longitude'), ylabel('latitude')
% --------------------------------------------------------------------------------
%% --------------------------------------------------------------------------------
% Parameters
% --------------------------------------------------------------------------------
% neuron number, we give that number and SOM functions find the exact size (msize)
nneur = 120;
% groups sizes (in number of columns)
groupsdim = [12, 24]; % 2 groups: ASST and (U10, V10)
%groupsdim = [12, 12, 12]; % 3 groups: ASST, U10 and V10
% --------------------------------------------------------------------------------
% 2S-SOM training parameter:
%
% - LAMBDA (a scalar or a vector): One from two: a very high scalar value in order to
% fix ALPHA and let BETA to evolve; or the inverse, small to allow ALPHA to
% evolve. In this case we give normally a list of values leting the function to
% train multiple cases, one for each LAMBDA and thus to obtain an "optimal"
% 2S-SOM case giving the "best performances" or least SOM distortion error.
%
% Here, an array linearly separated values:
lambda = 1:20;
% or for a logarithmical spacing from 0.1 to 100 in 25 steps, uncomment newt line:
%lambda = logspace(log10(0.1), log10(100), 25);
%
% --------------------------------------------------------------------------------
% 2S-SOM training parameter ETA:
%
% - A very high value (compared to LAMBDA) makes Beta parameters to be equal for each
% group variable (column) and constant 1/g, for g the size of the group. Or, it
% could be, as for LAMBDA, an array on values in ordet to search the best or
% least distortion error for a given ETA (maintaining inversely a high value of
% LAMBDA). In our case is a fixed and hight value:
eta = 1e5;
% --------------------------------------------------------------------------------
%% --------------------------------------------------------------------------------
% --------------------------------------------------------------------------------
%
% Calling the 2S-SOM training function
%
% --------------------------------------------------------------------------------
% --------------------------------------------------------------------------------
% CHOOSE ONE:
%
% THIS ==>
% simplest call of learn_2s_som ... here with minimal input arguments. There are
% many more input arguments, do help learn_2s_som or see the code for more.
[sMap, sMap_denorm, Result, sMapPT] = learn_2s_som(normdata, nneur, ...
's2-som', ...
'DimData',groupsdim, ...
'lambda',lambda, ...
'eta', eta);
%%
% OR BETTER, THIS ==>
% or with a struct as the return variable, you should explicitly specify the
% 'return-struct' option. and also other SOM options:
St2SSOM = learn_2s_som(normdata, nneur, ...
's2-som', ...
'DimData',groupsdim, ...
'lambda',lambda, ...
'eta', eta, ...
'init', 'randinit', ...
'lattice', 'hexa', ...
'return-struct');
%
% --------------------------------------------------------------------------------
% Return:
% St2SSOM, a struct with fields:
%
% sMap: [1x1 struct] <-- "best" sMap
% sD: [1x1 struct]
% lambda: 13 <--| LAMBDA and ETA prameters used for getting best
% eta: 100000 | sMap.
% bmus: [1x743 double] <-- best matching unit for each pattern in input data.
% Alpha: [117x2 double] <--| ALPHA and BETA coefficients obtained during the
% Beta: [1x2 struct] | 2S-SOM training.
% DimData: [12 24] <-- same as input dimdata
% sMapPT: [1x1 struct]
% Result: [1x20 struct] <--| Sequential results for all trainings realized
% | for all pairs of {lambda(i),eta{j}}
% iBest: 13 <-- index of the best training in RESULT list struct.
% --------------------------------------------------------------------------------
% --------------------------------------------------------------------------------
% See other LEARN_2S_SOM input arguments:
%
% (you can have help about variable significatuon looking some SOM functions, even if
% it's not a classic SOM training)
%
% -> General SOM arguments (ALL IN OPTION):
% 'data_name', data_name, ... (OPTION, string, any name, the default value is
% 'simulation', see 'name' in SOM_DATA_STRUCT)
% 'comp_names', comp_names, ... (OPTION, cell string list, names of each variable
% or column, see SOM_DATA_STRUCT)
% 'init', init, ... (OPTION, string, default 'lininit', see SOM_MAKE)
% 'lattice', lattice, ... (OPTION, string, default 'rect', see SOM_MAKE)
% 'radius', radius, ... (OPTION, vector, default [5 1], see SOM_BATCHTRAIN)
% 'trainlen', trainlen, ... (OPTION, scalar or vector, default 20, see
% SOM_BATCHTRAIN)
% 'tracking', tracking, ... (OPTION, scalar, default 0, see SOM_MAKE and
% SOM_BATCHTRAIN)
%
% -> Specific 2S-SOM arguments:
% 'radius-2s-som', radius_2s_som, ... (OPTION, vector, default last two
% elements of 'radius')
% 'trainlen-2s-som', trainlen_2s_som, ... (OPTION, scalar, default last element
% of 'trainlen'))
% 'DimData', GroupDimData, ... (MANDATORY)
% % one from LAMBDA or ETA is MANDATORY if you want 2S-SOM computation:
% 'lambda', lambda, ... (scalar or vector)
% 'eta', eta, ... (scalar or vector)
%
% See more in LEARN_2S_SOM code.
%
% Parallel computing:
%
% You can use:
% 'parcomp', parcomp_workers, .. (scalar, the number of treads or working in
% parallel, default 8)
%
% Note: even if 'parcomp' option is not used, LEARN_2S_SOM uses a PARFOR loop,
% activating some paralelism. You must enter the code and comment in line
% 444: (( parfor (i=1:n_lambda,parcomp_M) )) and comment out next one:
% (( for i = 1:n_lambda )) if you want to completely deactivate this
% parallel behaviour.
%
% --------------------------------------------------------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment