Skip to content

Commit

Permalink
MATLAB interface updated to include option for choosing neighborhood …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
peterwittek committed Nov 23, 2015
1 parent aaaa101 commit 1e6988b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/MATLAB/MexSomoclu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
}
mxFree(gridType_c);
bool compactSupport = (bool) mxGetPr(prhs[13])[0];

bool gaussian = (bool) mxGetPr(prhs[14])[0];

//Call train routine
train(data, data_length, nEpoch, nSomX, nSomY,
nDimensions, nVectors, radius0, radiusN,
radiusCooling, scale0, scaleN, scaleCooling,
kernelType, mapType, gridType, compactSupport,
kernelType, mapType, gridType, compactSupport, gaussian,
codebook, codebook_size, globalBmus, globalBmus_size,
uMatrix, uMatrix_size);

Expand Down
5 changes: 3 additions & 2 deletions src/MATLAB/mex_interface_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
mapType = 'planar';
gridType = 'rectangular';
compactSupport = false;
neighborhood = 'gaussian';
[sMap, sTrain, globalBmus, uMatrix] = somoclu_train(sMap, D, 'msize', msize, 'radius0', radius0, ...
'radiusN', radiusN, 'radiusCooling', radiusCooling, ...
'scale0', scale0, 'scaleN', scaleN, 'scaleCooling', scaleCooling, ...
'kernelType', kernelType, 'mapType', mapType, ...
'gridType', gridType, 'compactSupport', compactSupport, ...
'nEpoch', nEpoch);

'neighborhood', neighborhood, 'nEpoch', nEpoch);

10 changes: 9 additions & 1 deletion src/MATLAB/somoclu_train.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
% 'scaleCooling' 'alpha_type' (string) Learning rate cooling strategy: linear or exponential (default: linear)
% 'gridType' 'lattice' (string) Grid type: square or hexagonal (default: square)
% 'compactSupport' Compact support for map update (0: false, 1: true, default: 0)
% 'neighborhood' Neighborhood function (bubble or gaussian, default: gaussian)
% 'nEpoch' 'trainlen' (scalar) Maximum number of epochs
% 'sTrain','som_train ' = 'train'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -81,6 +82,7 @@
sTrain.alpha_type = 'linear';
sTrain.kernel_type = 0;
sTrain.compact_support = false;
sTrain.neighborhood = 'gaussian';
sTrain.scale0 = 0.1
sTrain.scaleN = 0.01

Expand Down Expand Up @@ -108,6 +110,7 @@
% if l>2, radius = varargin{i}; tlen_type = 'samples'; end
end
case {'scaleCooling', 'alpha_type'}, i=i+1; sTrain.alpha_type = varargin{i};
case 'neighborhood', i=i+1; sTrain.neighborhood = varargin{i};
case {'scale0', 'alpha_ini'}, i=i+1; sTrain.scale0 = varargin{i};
case 'scaleN', i=i+1; sTrain.scaleN = varargin{i};
case {'sTrain','train','som_train'}, i=i+1; sTrain = varargin{i};
Expand Down Expand Up @@ -137,13 +140,18 @@
end
i = i+1;
end
if strcmp(sTrain.neighborhood, 'gaussian')
sTrain.gaussian = 1;
else
sTrain.gaussian = 0;
end
[sMap.codebook, globalBmus, uMatrix] = MexSomoclu(D, sTrain.trainlen, ...
sTopol.msize(1), sTopol.msize(2), ...
sTrain.radius_ini, sTrain.radius_fin, ...
sTrain.radius_cooling, sTrain.scale0, sTrain.scaleN, ...
sTrain.alpha_type, ...
sTrain.kernel_type, sTopol.shape, sTopol.lattice, ...
sTrain.compact_support, sMap.codebook);
sTrain.compact_support, sTrain.gaussian, sMap.codebook);
rowNums=colon(1,size(globalBmus,1))'
globalBmus = [rowNums globalBmus]
sTrain = som_set(sTrain,'time',datestr(now,0));

0 comments on commit 1e6988b

Please sign in to comment.