Below is the code of applying SOM on handwritten digits recongnition. It was implemented for a homework assignment in a course offered by professor Paul Gader. I used only ten handwritten digits images provided by Dr. Gader. Each image is resized to 30×30 and reshape to a 900×1 column vector. data in the code below is the training set. It’s a coolection of 900-dimensional column vectors.

%//Matlab script
%//-- 10 x 10 map
data = double(data);
%// toal number of nodes
totalW = 100;
%//initialization of weights
w = rand(900, totalW);
%// the initial learning rate
eta0 = 0.1;
%// the current learning rate (updated every epoch)
etaN = eta0;
%// the constant for calculating learning rate
tau2 = 1000;
%//map index
[I,J] = ind2sub([10, 10], 1:100);
N = size(data,2);
alpha = 0.5;
%// the size of neighbor
sig0 = 200;
sigN = sig0;
%// tau 1 for updateing sigma
tau1 = 1000/log(sigN);
%i is number of epoch
for i=1:2000
%// j is index of each image.
%// it should iterate through data in a random order rewrite!!
for j=1:N
x = data(:,j);
dist = sum( sqrt((w - repmat(x,1,totalW)).^2),1);
%// find the winner
[v ind] = min(dist);
%// the 2-D index
ri = [I(ind), J(ind)];
%// distance between this node and the winner node.
dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] - repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;
%// updating weights
for rr = 1:100
w(:,rr) = w(:,rr) + dist(rr).*( x - w(:,rr));
end
end
%// update learning rate
etaN = eta0 * exp(-i/tau2);
%// update sigma
%sigN = sigN/2;
sigN = sig0*exp(-i/tau1);
%//show the weights every 100 epoch
if mod(i,200) == 1
figure;
axis off;
hold on;
for l = 1:100
[lr lc] = ind2sub([10, 10], l);
subplot(10,10,l);
axis off;
imagesc(reshape(w(:,l),30,30));
axis off;
end
hold off;
end
end

Result:
See the transition between different numbers? 🙂

it is wonderfull.thank u.But do u have linear vector quantization(lvq) algortihm with solving any problem in matlab code, if u could u send me pls??? Cause i need it urgently.Thank u a lot…Have a nice day.

Paul,
Sorry I have never implemented any linear vector quantization algorithm. Is k-means only of the way to do it? If yes, use the matlab built-in function kmeans(…).

thank u very much for your replying.but k-means algorithm and lvq are different wth each other.Up to me there is no relationship btwn them.i search in the internet but i did not get any code.how can i do? can u advise me pls???

thanx a lot but i need code in matlab 😦 by the way i do not know anything about matlab programming language.i know C,Java,ASP…etc but ı never seen matlab and i need the code about lvq…

each training data is a column vector stored in “data”. data is a of size 900xN where N is the number of training data you have. If you have data with dimensionality other than 900, you need to modify the code a little bit.

Thanks!
Why there is “1/sqrt(2*pi*sigN)” to calculate distance from the winnner?
I thought ‘distance = learning rate * neighborhood function’.
any reason???

chi3x10,
I read that you prefer answering questions here, not by messenger or email, am I right? First of all, thank you for making your code public. Abusing of your kindness, I have some doubts about SOM. I’ll make one for now. Can you say to me when to use unidimensional or bidimensional maps? Why use one of them.

Just for observation, I’m using Octave in Linux (similar to Matlab).

and are you sure the line:
dist = 1/sqrt(2*pi*sigN).*exp( sum(( ([I(:), J(:)] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;
is correct? shouldn’t sigN be squared?

It’s a two dimensional map consist of 10×10 output nodes. See the attached image which shows the weights of the 10×10 nodes.

You are right! I modified the equation to
dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I(:), J(:)] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;
Thanks for pointing out the mistake!

HI Chi,
I am trying to do clustering/ classification of a multidimentional data using SOM. I am new to SOM, and would really appreciate your help. The code you have uploaded is running but can you provide any of your papers or a book or notes from where you have laid the mathematics in the code. There are certain points like updating of sigma, learning rate, for which I am not able to find any equations similar to what is in the code. Also if possible please tell me how you came up with inital learning rate, constant of learning rate and size of the neighbour. I really look forward to hearing back from you. Thanks

You can reply me at vcoolboys@yahoo.com or here as per your convinience.
regards,
vikas

I can’t understand this line:
dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( , J( ] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

what is the smile icon?
I couldn’t run the code because of the following error:
??? Error: File: somm.m Line: 43 Column: 53
Unexpected MATLAB operator.

hi
i need help for this question:
As a very simple system of watermarking we want to hide a W × H gray–scale image, G,
in a W×H color image, I. The proposed method is to quantize G to 6 bpp and I to 3×6 bpp
(6 bit for each channel). Now G can easily be hidden in I. Develop code to hide and
extract the given G in the given I.

i do not know anything about matlab programming language.i need help for do it
please help me if u can as soon as u can:)

can u provide me som progarm for training n testing of huge dataset.As i have already go though the above mentioned program but why alpha has taken as 0.5.As firther it has no use atall…plz do reply me…

plz do give me som progarm for training n testing of huge dataset.As i have already go though the above mentioned program but why alpha has taken as 0.5.As further it has no use atall…plz do reply me…

Thank you for the code and your help in answering the questions.

I have a cube of uniformally distributed samples of size (12,25,50) equivalent (Z,Y,X).
So you can think of it as 12 maps/slices that are stacked.

I want to organize the maps by SOM to show different clusters for each map.

I know that SOM uses two process:
in the ‘Taining’ stage (where a sample from the input data is randomly selected), but in your code you are using all the data not samples, right?

Where do you separate between the ‘Training’ stage and the ‘Application’ stage?

Giving the size of my data (cube of size (12, 25, 50)),What will be good numbers for: # of Epoch,and # of Randomly selected input?

hi i am doing “adaptive noise cancellation using enhanced dynamic fuzzy neural mnetworks IEEE 2005 paper”
plz help me to develop “dynamic fuzzy neural network”
using matlab.

Can you please teach me on how to use the training neaural network using SOM…….Can you send me the procedures that can be done on testing the trained neural network….

Can you send me a codes on how to test the data after training…. I really dont know how to use the training data net on testing another data as input. .. I can only trained it but i dont really know how to test it.

Hi
I need the Self Organing map program in Matalab so I can use it for extracting trace from seismic 3D did some one have an idea where I can find that type of program

hi, can u give me some of ur pulished papers so that i can go through, ur code looks quitehelpful, at the same time, if u have sample cada it would be quite help ful, thank u, by the way how many output clusters does it have.

Hello!!!!!
I am new in machine learning and i am trying to implement a SVM with SOM ,the code above is very intresting and i want to use it in whole MNIST base and
take error results and training time

Hi,
I am new in machine learning and I am trying to implement a SVM with SOM so I want to do this for whole MNIST(train and test) and take error result(plot)…

hi .. i need to implement som for brain yumor detection.. can u plz explain d code for this pseudo code??
Procedure seg (image)
/* load the input image*/
Im = imread(image);
/* initialize the variable*/
Sigma=number of neighborhood pixels(8 or 24 or 48 or 80 or 120)
/*if sliding windoe size(3*3 =8),(5*5=24),(7*7=48),)(9*9=80),(11*11=120)*/
Sigma N= Sigma 0 * exp(-i/taul)
Taul= total number of pixels / log(neighborhood number of pixel)
/*Similarly find the sigma value for each and every pixel */
/* find the neighborhood function */
Nf(i)=Img(i)-img(i+1)*sigma(i)
/*find the weight vector*/
Wi(i+1)=wi+Nf(i)*img(i)-w(i)
/*find the winning neuron*/
Wn=max(wn,img(i)-w(img(i))
/* segmentation of som*/
Img(i)>=wn then
img(i)=1
Else
Img(i)=img(i)

hi .. i need to implement codebook using som from vector quantized coefficients of images for image compression.. ?
could you just help me in finding out the code for the same?

hi .. i need to implement som for brain yumor detection.. can u plz explain d code for this pseudo code??
Procedurnt e seg (image)
/* load the input image*/
Im = imread(image);
/* initialize the variable*/
Sigma=number of neighborhood pixels(8 or 24 or 48 or 80 or 120)
/*if sliding windoe size(3*3 =8),(5*5=24),(7*7=48),)(9*9=80),(11*11=120)*/
Sigma N= Sigma 0 * exp(-i/taul)
Taul= total number of pixels / log(neighborhood number of pixel)
/*Similarly find the sigma value for each and every pixel */
/* find the neighborhood function */
Nf(i)=Img(i)-img(i+1)*sigma(i)
/*find the weight vector*/
Wi(i+1)=wi+Nf(i)*img(i)-w(i)
/*find the winning neuron*/
Wn=max(wn,img(i)-w(img(i))
/* segmentation of som*/
Img(i)>=wn then
img(i)=1
Else
Img(i)=img(i)

plz plz help me out if you cannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
give me hint about neighbour hood function

this is brain tumor detection code which is given in a reaseach paper by karan namely as ‘AN improved imoplementation of brain tumour detection ‘ PLZ for GOD sake any one help me

Hi,
I have a multi dimensional input(5), and I want to use the program to cluster the data, based upon the class(I know the class). I was able to do the clustering part, but my problem now is to map that data clusters into 2-D neuron grid, and see if actually neurons are clustered. In the above code I changed 900 to 5 etc. But I need help in plotting. I know images(…) doesnt work for me. Any idea anyone? (P.S I have also made little changes in the program to list all the winning neurons in case of each input.. I have 1000 input data values).

Kindly clarify how this data is sent to training as we are not updating ‘data’. As your code able to find transitions, how it could give different labels to data? Thanks is advance.

%// distance from the winnner
dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;
Kindly make this line discernible. What these lines stand for? What does the “distance from the winner” mean here?

I need to run self organize map on seismic volume for classification for diffrent attributes but I want the result to be in 3D volume instead of 2D view did nybody has a code for that?

hi paul
myself rohit jain. i have to find mean square error by som. can you u help me by giving me a matlab code for it.
please reply me on maxi2623@gmail.com

Hi
This is for segmentation
clc
clear all
%//Matlab script

%data = double(data);
data=imread(‘test.jpg’);
[r,c]=size(data);
new_r=r*c;
data = reshape(data,new_r,1);
%// toal number of nodes
r_map=2;
c_map=6;
Total_node=r_map*c_map;

totalW = Total_node;
%//initialization of weights

max_value=max(data);

w = rand(new_r, totalW);

%// the initial learning rate
eta0 = 0.1;

%// the current learning rate (updated every epoch)
etaN = eta0;

%// the constant for calculating learning rate
tau2 = 1000;

%//map index
[I,J] = ind2sub([r_map, c_map], 1:Total_node);

N = size(data,2);

alpha = 0.5;
%// the size of neighbor
sig0 = 200;

sigN = sig0;
%// tau 1 for updateing sigma
tau1 = 1000/log(sigN);

%i is number of epoch
for i=1:1000
%// j is index of each image.
%// it should iterate through data in a random order rewrite!!
for j=1:N
x = double(data(:,j));

%//show the weights every 100 epoch
if mod(i,200) == 1
figure;
axis off;
hold on;
for l = 1:Total_node
[lr lc] = ind2sub([r_map, c_map], l);
subplot(r_map,c_map,l);
axis off;
imagesc(reshape(w(:,l),r,c));
axis off;
end
hold off;
end
end

clc
clear all
%//Matlab script

%data = double(data);
data=imread(‘test.jpg’);
[r,c]=size(data);
new_r=r*c;
data = reshape(data,new_r,1);
%// toal number of nodes
r_map=2;
c_map=6;
Total_node=r_map*c_map;

totalW = Total_node;
%//initialization of weights

max_value=max(data);

w = rand(new_r, totalW);

%// the initial learning rate
eta0 = 0.1;

%// the current learning rate (updated every epoch)
etaN = eta0;

%// the constant for calculating learning rate
tau2 = 1000;

%//map index
[I,J] = ind2sub([r_map, c_map], 1:Total_node);

N = size(data,2);

alpha = 0.5;
%// the size of neighbor
sig0 = 200;

sigN = sig0;
%// tau 1 for updateing sigma
tau1 = 1000/log(sigN);

%i is number of epoch
for i=1:1000
%// j is index of each image.
%// it should iterate through data in a random order rewrite!!
for j=1:N
x = double(data(:,j));

%//show the weights every 100 epoch
if mod(i,200) == 1
figure;
axis off;
hold on;
for l = 1:Total_node
[lr lc] = ind2sub([r_map, c_map], l);
subplot(r_map,c_map,l);
axis off;
imagesc(reshape(w(:,l),r,c));
axis off;
end
hold off;
end
end

May I know why you have the term “1/(sqrt(2*pi)*sigN)” in the weights update equation. I believe your lecturer was following NN by Simon Haykins, and so couldn’t fit it into the descriptions in the book.

W = W + N(n) h(n) * (x – W)

N(n) is the time-varying learning parameter and h(n) is the time-varying neighbourhood function. Both of them don’t have a “1/(sqrt(2*pi)*sigN)” in their terms.

Excellent blog here! Also your web site loads up fast! What host are you using?
Can I get your affiliate link to your host? I wish my website loaded up as quickly
as yours lol

ӏ simply couldn’t go aaաay yߋur site before suggesting
that I xtremely enjoƴed the usual info an individual suρply on youг visitorѕ?
Is gonna be Ƅack often to check oսt new posts

Hi, I was trying this code using finger print images and it came with an error that “Error using –
Matrix dimensions must agree.”
What have I done wrong.

This is the only change I made
data = double (‘C:\Users\Makhosi\Desktop\Project\finger_Print_Images\’);

HI Chi,
I am trying to do clustering/ classification of a multidimentional data using SOM. I am new to SOM, and would really appreciate your help. Can you provide some more code example about SOM(Hello world-color classification code)

I really look forward to hearing back from you. Thanks

I have the same problem:( If u solved your problem, could u pls help me how you achieved this? I need the code of SOM for clustering to multidimentional data very urgently:(

hi,
My project is related to gesture recognition using som-Hebb classifier. i have used SOM code similar to you algo. But i am unable to map hebb with it . And i think there is need for optimization? Can you send me source code of SOM-Hebb code which can give proper results during classification.

it is wonderfull.thank u.But do u have linear vector quantization(lvq) algortihm with solving any problem in matlab code, if u could u send me pls??? Cause i need it urgently.Thank u a lot…Have a nice day.

please Paul if u understand this code so what’s data here and how these images be readen

i need som based classifiction for any object!!

😦 there is no reply

Paul,

Sorry I have never implemented any linear vector quantization algorithm. Is k-means only of the way to do it? If yes, use the matlab built-in function kmeans(…).

Jason

thank u very much for your replying.but k-means algorithm and lvq are different wth each other.Up to me there is no relationship btwn them.i search in the internet but i did not get any code.how can i do? can u advise me pls???

http://en.wikipedia.org/wiki/Vector_quantization

thanx a lot but i need code in matlab 😦 by the way i do not know anything about matlab programming language.i know C,Java,ASP…etc but ı never seen matlab and i need the code about lvq…

Please can you send me the matlab code for SOM.This code does not work.Please help me:(In the fourth line there occurs a data problem

Jack,

“data” is a 2d array contains collection of column vectors that you want to train your SOM.

can you give me an example?

chi3x10 Says: , can u add me on MSN, l_h_mak@hotmail.com, i need your guide on SOM, Pls ..

Mak,

Post your questions here. I am sure we can solve the problems here.

kmeans code in matlab does not work.can u help me in finding out the correct code

gonna try this out…

thanks!

oh ya, how do I make the train data?

each training data is a column vector stored in “data”. data is a of size 900xN where N is the number of training data you have. If you have data with dimensionality other than 900, you need to modify the code a little bit.

Thanks!

Why there is “1/sqrt(2*pi*sigN)” to calculate distance from the winnner?

I thought ‘distance = learning rate * neighborhood function’.

any reason???

1/sqrt(2*pi*sigN) is the normalization factor.

sir,it is nice and easy in understanding.Do u hav any sample code for the background subtraction by using som

chi3x10,

I read that you prefer answering questions here, not by messenger or email, am I right? First of all, thank you for making your code public. Abusing of your kindness, I have some doubts about SOM. I’ll make one for now. Can you say to me when to use unidimensional or bidimensional maps? Why use one of them.

Just for observation, I’m using Octave in Linux (similar to Matlab).

Sorry for any English mistakes, I’m brazilian.

flashfs,

It depends on the topological property of the data in original feature space. My code here is 2D.

Jason

chi3x10,

Can you tell me one example of a set of data that it would be good to use a unidimensional map?

chi3x10,

thanks for sahring your code!

I’m not familiar with SOM conventions, but distance seems to be related to INVERSE

distance (higher when nearer), correct?

(Seems to make sense, since weight update is heavier when nearer then)

Also, having this map now how do you classify a new input vector? I assume: find nearest node. Correct, or is there a fancier method?

Cheers,

Luuk

At line 35, are you sure it is sum(sqrt(…)) and not sqrt(sum(…))?

what exactly is a 10 x 10 map?

and are you sure the line:

dist = 1/sqrt(2*pi*sigN).*exp( sum(( ([I(:), J(:)] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

is correct? shouldn’t sigN be squared?

It’s a two dimensional map consist of 10×10 output nodes. See the attached image which shows the weights of the 10×10 nodes.

You are right! I modified the equation to

dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I(:), J(:)] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

Thanks for pointing out the mistake!

Sir, please send me matlab coding of Kohonen network including each step of Self-organizing map.

nice job!

thanks to chi3x10.

I’ll stay tuned.

bye.

can you tell me how I can use this program for clustering of data.

.

HI Chi,

I am trying to do clustering/ classification of a multidimentional data using SOM. I am new to SOM, and would really appreciate your help. The code you have uploaded is running but can you provide any of your papers or a book or notes from where you have laid the mathematics in the code. There are certain points like updating of sigma, learning rate, for which I am not able to find any equations similar to what is in the code. Also if possible please tell me how you came up with inital learning rate, constant of learning rate and size of the neighbour. I really look forward to hearing back from you. Thanks

You can reply me at vcoolboys@yahoo.com or here as per your convinience.

regards,

vikas

Hi

I can’t understand this line:

dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( , J( ] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

what is the smile icon?

I couldn’t run the code because of the following error:

??? Error: File: somm.m Line: 43 Column: 53

Unexpected MATLAB operator.

It should be

# dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

wordpress automatically convert

( : )to a ( and a smiley face.hi

i need help for this question:

As a very simple system of watermarking we want to hide a W × H gray–scale image, G,

in a W×H color image, I. The proposed method is to quantize G to 6 bpp and I to 3×6 bpp

(6 bit for each channel). Now G can easily be hidden in I. Develop code to hide and

extract the given G in the given I.

i do not know anything about matlab programming language.i need help for do it

please help me if u can as soon as u can:)

sa-ti traiasca familia!!!

i try run the code,

but it can’t be accomplished..

it prints the error

“data are uninitialised”..

how can i fix this error?

tq

Hi thanx for the code

How to I cluster multidimensional data?

Is it possible with the above code?

what do I have to modify?

Thank you

Hema,

The code is of course for multidimensional data.

thanks for this code

but where are data to be use

hi chi3

can the code run for input vector

29 * 16 matrix?

Hi, kh,

Yes, it can but you have to modify the code a little bit.

Thanks for this code. It was very useful to me.

Can you please provide me the code in matlab for SOM clustering for detection of IP Spoofing

can you please provide me the code in matlab for multi som or generilzation of som

hi thanks very much plz send me your dataset

i want to know has it any problem that i use your code for my homework.

thank very much

thanks alot

i want matlab code for self organizing graph

i want to use som in graph layout based on a competitive learning algorithm

Thank you for this code, would you please give me your data ,I am new in matlab

can u provide me som progarm for training n testing of huge dataset.As i have already go though the above mentioned program but why alpha has taken as 0.5.As firther it has no use atall…plz do reply me…

plz do give me som progarm for training n testing of huge dataset.As i have already go though the above mentioned program but why alpha has taken as 0.5.As further it has no use atall…plz do reply me…

@Laxmi

alpha can be any number. It was chosen to be 0.5 empirically here.

Dear chi3x10,

Thank you for the code and your help in answering the questions.

I have a cube of uniformally distributed samples of size (12,25,50) equivalent (Z,Y,X).

So you can think of it as 12 maps/slices that are stacked.

I want to organize the maps by SOM to show different clusters for each map.

I know that SOM uses two process:

in the ‘Taining’ stage (where a sample from the input data is randomly selected), but in your code you are using all the data not samples, right?

Where do you separate between the ‘Training’ stage and the ‘Application’ stage?

Giving the size of my data (cube of size (12, 25, 50)),What will be good numbers for: # of Epoch,and # of Randomly selected input?

Please reply to my questions.. Thanks.

Hi chi3×10,

excellent post!

have u any link where i can find the data trainning set that u use?

Thanx a lot

Can you please answer my questions?

Add me to coyotus1@hotmail.com I can help you with the data train set.

hi i am doing “adaptive noise cancellation using enhanced dynamic fuzzy neural mnetworks IEEE 2005 paper”

plz help me to develop “dynamic fuzzy neural network”

using matlab.

Can you please teach me on how to use the training neaural network using SOM…….Can you send me the procedures that can be done on testing the trained neural network….

Can you send me a codes on how to test the data after training…. I really dont know how to use the training data net on testing another data as input. .. I can only trained it but i dont really know how to test it.

Hi

I need the Self Organing map program in Matalab so I can use it for extracting trace from seismic 3D did some one have an idea where I can find that type of program

Can you send me SOM code in matlab please I need your help.

hi,i am doing artical(inhanced self organization incremental neural network for unsupervice learning)

please help me to code using matlab.

hi, can you me ESOINN OR ESOM code in matlab please i need your help.tank.

I m doing a project titled “Content Based Video Retrieval Using Fuzzzy Logic”. Can u plz send me the matlab code? Thank you.

how to provide input to this SOM?

the code that is given is running but i am unable to understand what output is shown in figures (how the data is classified).plz.. help me its urgent…

sir,

pls may i know the code to classify normal and abnormal images using SOM.

hi, can u give me some of ur pulished papers so that i can go through, ur code looks quitehelpful, at the same time, if u have sample cada it would be quite help ful, thank u, by the way how many output clusters does it have.

hi…i’m trouble using your code…the problem is

??? Error using ==> minus Matrix dimensions must agree. Error in ==> som at 37 dist = sum( sqrt((w – repmat(x,1,totalW)).^2),1);

can u help me…thanks

IS THERE ANY BODY WHO TELL ME HOW I SOLVE THIS ERROR

??? Error using ==> times

Matrix dimensions must agree.

Error in ==> som at 116

weights = weights(:,rr) + dist().*( x – weights(:,rr));

sorry the error is like that not above one

??? Attempted to access weights(:,2); index out of bounds because

size(weights)=[32,1].

Error in ==> som at 116

weights = weights(:,rr) + dist(rr).*( x – weights(:,rr));

i give data as 10*10 matrix but i got this error,how can i solve thi error?

??? Error using ==> minus

Matrix dimensions must agree.

Error in ==> Untitled at 38

dist = sum( sqrt((w – repmat(x,1,

Hello!!!!!

I am new in machine learning and i am trying to implement a SVM with SOM ,the code above is very intresting and i want to use it in whole MNIST base and

take error results and training time

I need help please!!!!!!!!!

Thanks in advance!!

Please help me I dont have mutch time!!!

Is my school project!!!

Hi,

I am new in machine learning and I am trying to implement a SVM with SOM so I want to do this for whole MNIST(train and test) and take error result(plot)…

Please help me

Thanks in advance!!!

hi…i’m trouble using your code..

??? Error using ==> minus Matrix dimensions must agree. Error in ==> som at 37 dist = sum( sqrt((w – repmat(x,1,totalW)).^2),1);

can u help me please…thank u

hi,

could you just help me in finding out the code related to “Dynamic Hierechial SOM”

thanx

hi,

could you just help me in finding out the code related to “Dynamic adaptive SOM”

thanx

hi i want coding for the som algorithm in java or c

if u have plz send to me

rama414@gmail.com is my main id

hi .. i need to implement som for brain yumor detection.. can u plz explain d code for this pseudo code??

Procedure seg (image)

/* load the input image*/

Im = imread(image);

/* initialize the variable*/

Sigma=number of neighborhood pixels(8 or 24 or 48 or 80 or 120)

/*if sliding windoe size(3*3 =8),(5*5=24),(7*7=48),)(9*9=80),(11*11=120)*/

Sigma N= Sigma 0 * exp(-i/taul)

Taul= total number of pixels / log(neighborhood number of pixel)

/*Similarly find the sigma value for each and every pixel */

/* find the neighborhood function */

Nf(i)=Img(i)-img(i+1)*sigma(i)

/*find the weight vector*/

Wi(i+1)=wi+Nf(i)*img(i)-w(i)

/*find the winning neuron*/

Wn=max(wn,img(i)-w(img(i))

/* segmentation of som*/

Img(i)>=wn then

img(i)=1

Else

Img(i)=img(i)

plz anyone help me out wit Sigma N…

hi i want coding for the som algorithm in java or c

if u have plz send to me

rama414@gmail.com is my main id

thanks for these code it will help

plz anyone help me out wid determinstic sigmoid belief network.

hi .. i need to implement codebook using som from vector quantized coefficients of images for image compression.. ?

could you just help me in finding out the code for the same?

WHERE IS DATA…?

hi .. i need to implement som for brain yumor detection.. can u plz explain d code for this pseudo code??

Procedurnt e seg (image)

/* load the input image*/

Im = imread(image);

/* initialize the variable*/

Sigma=number of neighborhood pixels(8 or 24 or 48 or 80 or 120)

/*if sliding windoe size(3*3 =8),(5*5=24),(7*7=48),)(9*9=80),(11*11=120)*/

Sigma N= Sigma 0 * exp(-i/taul)

Taul= total number of pixels / log(neighborhood number of pixel)

/*Similarly find the sigma value for each and every pixel */

/* find the neighborhood function */

Nf(i)=Img(i)-img(i+1)*sigma(i)

/*find the weight vector*/

Wi(i+1)=wi+Nf(i)*img(i)-w(i)

/*find the winning neuron*/

Wn=max(wn,img(i)-w(img(i))

/* segmentation of som*/

Img(i)>=wn then

img(i)=1

Else

Img(i)=img(i)

plz plz help me out if you cannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

give me hint about neighbour hood function

please I don’t get wht’s Data here in this code

this is brain tumor detection code which is given in a reaseach paper by karan namely as ‘AN improved imoplementation of brain tumour detection ‘ PLZ for GOD sake any one help me

what is diff between dist@line 35 and dist@line 43

Hi every body, please if any body have SOM code in matlab for skin segmentation inform.thank you.

Hi…. Im doing unsupervised remote sensing change detection… (o/p will be binary map) Plz can anyone help me to code using matlab

I want 2 segment the image using SOM,If any one have any source code in matlab please send me.

@Sourav Paul

did you find any matlab code?

Hi,

I have a multi dimensional input(5), and I want to use the program to cluster the data, based upon the class(I know the class). I was able to do the clustering part, but my problem now is to map that data clusters into 2-D neuron grid, and see if actually neurons are clustered. In the above code I changed 900 to 5 etc. But I need help in plotting. I know images(…) doesnt work for me. Any idea anyone? (P.S I have also made little changes in the program to list all the winning neurons in case of each input.. I have 1000 input data values).

it worked for me…had to change it a little bit…

but hey, thanks for the help …it helped a lot..

keep up the good work.

Good code but What present code indicate?

Kindly clarify how this data is sent to training as we are not updating ‘data’. As your code able to find transitions, how it could give different labels to data? Thanks is advance.

%// distance from the winnner

dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

Kindly make this line discernible. What these lines stand for? What does the “distance from the winner” mean here?

hai,

i need self organizing map(som) matlab code for classification of remote sensing images….please help me…please reply to may mail id…thank you

Hi Guys

I need to run self organize map on seismic volume for classification for diffrent attributes but I want the result to be in 3D volume instead of 2D view did nybody has a code for that?

Hi, i need matlab code to train the som neural network. Please send me…

hello

i cannot run this code.’data ‘is the problem.anybody help me to run this program?

my id momotaz.2k3@gmail.com

Why do you choose a 10×10 matrix?

Ahaa, its nice discussion concerning this post at this place at this webpage, I have read all that,

so at this time me also commenting here.

hi paul

myself rohit jain. i have to find mean square error by som. can you u help me by giving me a matlab code for it.

please reply me on maxi2623@gmail.com

Hi

This is for segmentation

clc

clear all

%//Matlab script

%data = double(data);

data=imread(‘test.jpg’);

[r,c]=size(data);

new_r=r*c;

data = reshape(data,new_r,1);

%// toal number of nodes

r_map=2;

c_map=6;

Total_node=r_map*c_map;

totalW = Total_node;

%//initialization of weights

max_value=max(data);

w = rand(new_r, totalW);

%// the initial learning rate

eta0 = 0.1;

%// the current learning rate (updated every epoch)

etaN = eta0;

%// the constant for calculating learning rate

tau2 = 1000;

%//map index

[I,J] = ind2sub([r_map, c_map], 1:Total_node);

N = size(data,2);

alpha = 0.5;

%// the size of neighbor

sig0 = 200;

sigN = sig0;

%// tau 1 for updateing sigma

tau1 = 1000/log(sigN);

%i is number of epoch

for i=1:1000

%// j is index of each image.

%// it should iterate through data in a random order rewrite!!

for j=1:N

x = double(data(:,j));

%d=sqrt(sum(abs(w_final-repmat(r1,row2,1)).^2,2));

dist = sum( sqrt((w – repmat(x,1,totalW)).^2),1);

%// find the winner

[v ind] = min(dist);

%// the 2-D index

ri = [I(ind), J(ind)];

%// distance between this node and the winner node.

dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

%// updating weights

for rr = 1:Total_node

w(:,rr) = w(:,rr) + dist(rr).*( x – w(:,rr));

end

end

%// update learning rate

etaN = eta0 * exp(-i/tau2);

%// update sigma

%sigN = sigN/2;

sigN = sig0*exp(-i/tau1);

%//show the weights every 100 epoch

if mod(i,200) == 1

figure;

axis off;

hold on;

for l = 1:Total_node

[lr lc] = ind2sub([r_map, c_map], l);

subplot(r_map,c_map,l);

axis off;

imagesc(reshape(w(:,l),r,c));

axis off;

end

hold off;

end

end

clc

clear all

%//Matlab script

%data = double(data);

data=imread(‘test.jpg’);

[r,c]=size(data);

new_r=r*c;

data = reshape(data,new_r,1);

%// toal number of nodes

r_map=2;

c_map=6;

Total_node=r_map*c_map;

totalW = Total_node;

%//initialization of weights

max_value=max(data);

w = rand(new_r, totalW);

%// the initial learning rate

eta0 = 0.1;

%// the current learning rate (updated every epoch)

etaN = eta0;

%// the constant for calculating learning rate

tau2 = 1000;

%//map index

[I,J] = ind2sub([r_map, c_map], 1:Total_node);

N = size(data,2);

alpha = 0.5;

%// the size of neighbor

sig0 = 200;

sigN = sig0;

%// tau 1 for updateing sigma

tau1 = 1000/log(sigN);

%i is number of epoch

for i=1:1000

%// j is index of each image.

%// it should iterate through data in a random order rewrite!!

for j=1:N

x = double(data(:,j));

%d=sqrt(sum(abs(w_final-repmat(r1,row2,1)).^2,2));

dist = sum( sqrt((w – repmat(x,1,totalW)).^2),1);

%// find the winner

[v ind] = min(dist);

%// the 2-D index

ri = [I(ind), J(ind)];

%// distance between this node and the winner node.

dist = 1/(sqrt(2*pi)*sigN).*exp( sum(( ([I( : ), J( : )] – repmat(ri, totalW,1)) .^2) ,2)/(-2*sigN)) * etaN;

%// updating weights

for rr = 1:Total_node

w(:,rr) = w(:,rr) + dist(rr).*( x – w(:,rr));

end

end

%// update learning rate

etaN = eta0 * exp(-i/tau2);

%// update sigma

%sigN = sigN/2;

sigN = sig0*exp(-i/tau1);

%//show the weights every 100 epoch

if mod(i,200) == 1

figure;

axis off;

hold on;

for l = 1:Total_node

[lr lc] = ind2sub([r_map, c_map], l);

subplot(r_map,c_map,l);

axis off;

imagesc(reshape(w(:,l),r,c));

axis off;

end

hold off;

end

end

hi, thanx for ur code it works so well, now my problem is finding the index it’s giving me wrong values

hi chi3x10

i used your code and for reading data :

data=imread(3.jpg)

but the error showed:

??? Error using ==> minus

Matrix dimensions must agree.

Error in ==> digits at 35

dist = sum( sqrt((w –

repmat(x,1,totalW)).^2),1);

can you help me ?

hello, i want to ask u about the code. do u know the coding for imputation of missing data problem

hi pls tell how to segment the web page using som algorithm . i need solution soon please update need source code yaar.

hi paul,

I Apriyanto, I need a code to determine the threshold value of the SOM algorithm

please reply to email: 192apriyanto.jr @ gmail.com

Thank you …

hi , i need a data set to impelementation of SOM or WebSOM, please help me and send me a data set .tnx

Hi Jason,

May I know why you have the term “1/(sqrt(2*pi)*sigN)” in the weights update equation. I believe your lecturer was following NN by Simon Haykins, and so couldn’t fit it into the descriptions in the book.

W = W + N(n) h(n) * (x – W)

N(n) is the time-varying learning parameter and h(n) is the time-varying neighbourhood function. Both of them don’t have a “1/(sqrt(2*pi)*sigN)” in their terms.

Hope this finds you well!

Thanks!

Bharath

Excellent blog here! Also your web site loads up fast! What host are you using?

Can I get your affiliate link to your host? I wish my website loaded up as quickly

as yours lol

thanks

thanks for this code, its best

i have question about how we can access to each cluster data ??

ӏ simply couldn’t go aaաay yߋur site before suggesting

that I xtremely enjoƴed the usual info an individual suρply on youг visitorѕ?

Is gonna be Ƅack often to check oսt new posts

do u hav any matlab code for dimention reduction by SOM technique for speech features

how can i use code on datasets for prediction, at end, i am difficult to evalue, which project belong to which project

////?????

Hi, I was trying this code using finger print images and it came with an error that “Error using –

Matrix dimensions must agree.”

What have I done wrong.

This is the only change I made

data = double (‘C:\Users\Makhosi\Desktop\Project\finger_Print_Images\’);

HI Chi,

I am trying to do clustering/ classification of a multidimentional data using SOM. I am new to SOM, and would really appreciate your help. Can you provide some more code example about SOM(Hello world-color classification code)

I really look forward to hearing back from you. Thanks

You can reply me at anuja.bokhare@sicsr.ac.in or here as per your convinience.

regards,

anuja

Hello,

I have the same problem:( If u solved your problem, could u pls help me how you achieved this? I need the code of SOM for clustering to multidimentional data very urgently:(

awaiting your email with returning.

Thanks alot,

SU

what is data in the code pl reply

Hi Chi,

Thank you very much for posting the code. 🙂

hi,

My project is related to gesture recognition using som-Hebb classifier. i have used SOM code similar to you algo. But i am unable to map hebb with it . And i think there is need for optimization? Can you send me source code of SOM-Hebb code which can give proper results during classification.

I want to use SOM as classification purpose. Can you please provide me the code??

hi, i have the same pb please can you send me the code?