Professional Documents
Culture Documents
Project Report: " Kohonen Self Organizing Map
Project Report: " Kohonen Self Organizing Map
Submitted for CAL in B.Tech Neural Networks and Fuzzy Logic (EEE1007)
Submitted by
Slot: E1
April 2017
i
CERTIFICATE
This is to certify that the Project work entitled “Kohonen Self organizing map” that is
being submitted by “Abhilash Pani, Akash Singh and Vaibhav” for CAL in B.Tech
Neural Networks and Fuzzy Logic (EEE1007) is a record of bonafide work done under
our supervision. The contents of this Project work have not been submitted for any other
CAL course.
Place : Chennai
Signature of students:
Abhilash Pani
Akash Singh
Vaibhav
ii
CONTENTS
ACKNOWLEDGEMENTS………………………………………………………...iv
ABSTRACT………………………………………………………………………iv
1. Introduction………………………………………………….......................v
3. References...................................................................................................xi
ACKNOWLEDGEMENTS
ACKNOWLEDGEMENTS
iii
ACKNOWLEDGEMENTS
It is our duty to thank the faculty of SELECT, Dr Angalaeswari, for giving us valuable
inputs and most importantly our faculty, Ms Deepa T, for her invaluable guidance and
support throughout the entire semester and giving us this opportunity to make this project
possible
Abhilash Pani
Akash Singh
Vaibhav
iv
ABSTRACT
This project report is a detailed explanation about the idea that went into building the
code for Kohonen self-organizing map. The code, built to be used in MATLAB, works to
different parts of he network to respond similarly to certain input patterns. It has been
programmed in such a way that it can present the result almost immediately.
The aim here is to analyze the use of Artificial Neural Network in clinical and diagnostic
approaches through selected examples.
The use of neural network in diagnosing fever, through definite medical example,
showing the output state.
Segmentation of Brain Tumor from Magnetic Resonance Images, using Kohonen Model
of Artificial Neural Network.
v
1. Introduction
What is a Self organizing map?
vi
information is handled in separate parts of the cerebral cortex in the
human brain.
The weights of the neurons are initialized either to small random
values or sampled evenly from the subspace spanned by the two
largest principal component eigenvectors. With the latter alternative,
learning is much faster because the initial weights already give a good
approximation of SOM weights.
The network must be fed a large number of example vectors that
represent, as close as possible, the kinds of vectors expected during
mapping. The examples are usually administered several times as
iterations.
The training utilizes competitive learning. When a training example is
fed to the network, its Euclidean distance to all weight vectors is
computed. The neuron whose weight vector is most similar to the
input is called the best matching unit (BMU). The weights of the
BMU and neurons close to it in the SOM lattice are adjusted towards
the input vector. The magnitude of the change decreases with time and
with distance (within the lattice) from the BMU.
Diagnosing Fever:
The rescaled temperature for patients are noted and targets are found using
threshold.
Using Gradient descent method along with Logistic function and delta rule
for updation of weights.
Random values for weights, and bias are initialized along with learning rate.
Output is obtained using logistic activation function.
Square error is calculated, weights are updated using Delta rule.
The iteration or epoch is done until the square error is zero.
vii
Random input and weights are initialized.
Squared Euclidian distance is calculated, winning cluster is found out by
comparing for minimum distance.
Updating the weight matrix, and iterating for the given number.
After the iteration is over displaying the output, using drawnow command
for flushing the input every time.
The Code
% Self organizing map Kohonen
clc
clear all
close all
for i=1:1000
Input_1(i)=rand;%Inputs been given randomly
Input_2(i)=rand;%Inputs been given randomly
end
display(Input_1)
display(Input_2)
for j1=1:10
for j2=1:10
Weight_1(j1,j2)=rand*0.04+0.6;%weights have been given
randomly
Weight_2(j1,j2)=rand*0.04+0.6;%weights have been given
randomly
end
end
%display(Weight_1)
%display(Weight_2)
figure(1)
plot(Input_1,Input_2,'.b')
hold on
plot(Weight_1,Weight_2,'or')
plot(Weight_1,Weight_2,'k','linewidth',2)
plot(Weight_1',Weight_2','k','linewidth',2)
hold off
title('t=0');
drawnow;%MATLAB command for flushing the input everytime at output
screen.
no=1;
do=5;
T=10;%number of iteration for self-organising
t=1;
while (t<=T)
n=no*(1-t/T);%for making learning rate decrease with according
viii
to 10*10 matrix
%display(n)
d=round(do*(1-t/T));
%display(d)
%loop for the 1000 inputs
for i=1:1000
Euclidean_distance=(Input_1(i)-Weight_1).^2+(Input_2(i)-
Weight_2).^2;%minimum distance stored
%display(Euclidean_distance)
minj1=1;
minj2=1;
min_norm=Euclidean_distance(minj1,minj2);%initialisig the
first 1 x 1 matrix as minimum for reference
%display(min_norm)
for j1=1:10
for j2=1:10
if Euclidean_distance(j1,j2)<min_norm
min_norm=Euclidean_distance(j1,j2);%swapping the
values for minimum
minj1=j1;%taking the minimum position( may be
first column)
minj2=j2;%taking the minimum position(may be
second is row)
end
end
end
min_position_1= minj1;%assigning the minimum element
position
min_position_2= minj2;%assigning the minimum element
position
%display(min_position_1 )
%display(min_position_2)
%update the winning neuron
Weight_1(min_position_1,min_position_2)=Weight_1(min_position_1,min_
position_2)+n*(Input_1(i)- Weight_1(min_position_1,min_position_2));
Weight_2(min_position_1,min_position_2)=Weight_2(min_position_1,min_
position_2)+n*(Input_2(i)- Weight_2(min_position_1,min_position_2));
Weight_1(min_pos_1,min_pos_2)=Weight_1(min_pos_1,min_pos_2)+n*(Input
_1(i)-Weight_1(min_pos_1,min_pos_2));
Weight_2(min_pos_1,min_pos_2)=Weight_2(min_pos_1,min_pos_2)+n*(Input
_2(i)-Weight_2(min_pos_1,min_pos_2));
end
min_pos_1=min_position_1+dd;%vertically updating
min_pos_2=min_position_2;
ix
if (min_pos_1<=10)
Weight_1(min_pos_1,min_pos_2)=Weight_1(min_pos_1,min_pos_2)+n*(Input
_1(i)-Weight_1(min_pos_1,min_pos_2));
Weight_2(min_pos_1,min_pos_2)=Weight_2(min_pos_1,min_pos_2)+n*(Input
_2(i)-Weight_2(min_pos_1,min_pos_2));
end
min_pos_1=min_position_1;
min_pos_2=min_position_2-dd; %horizontally updating
if (min_pos_2>=1)
Weight_1(min_pos_1,min_pos_2)=Weight_1(min_pos_1,min_pos_2)+n*(Input
_1(i)-Weight_1(min_pos_1,min_pos_2));
Weight_2(min_pos_1,min_pos_2)=Weight_2(min_pos_1,min_pos_2)+n*(Input
_2(i)-Weight_2(min_pos_1,min_pos_2));
end
min_pos_1=min_position_1;
min_pos_2=min_position_2+dd;%horizontally updating
if (min_pos_2<=10)
Weight_1(min_pos_1,min_pos_2)=Weight_1(min_pos_1,min_pos_2)+n*(Input
_1(i)-Weight_1(min_pos_1,min_pos_2));
Weight_2(min_pos_1,min_pos_2)=Weight_2(min_pos_1,min_pos_2)+n*(Input
_2(i)-Weight_2(min_pos_1,min_pos_2));
end
end
end
t=t+1;
figure(1)
plot(Input_1,Input_2,'.b')
hold on
plot(Weight_1,Weight_2,'or')
plot(Weight_1,Weight_2,'k','linewidth',2)
plot(Weight_1',Weight_2','k','linewidth',2)
hold off
title(['t=' num2str(t)]);
drawnow;
pause(1)
end
x
xi
2. Conclusion
Self organizing map is one of the most challenging and advanced technology with
many application in the field of Science and Research and is being used for many
medical purposes. The reason for choosing Kohonen Algorithm is to learn the
practical aspect of what is being taught in the classroom as it is a part of the
syllabus. One of the main application of this program is to detect tumor in Human
brain.
We conclude that a Kohonen model is capable of classifying the patients as
having glomerular or tubular disease with a high sensitivity and predictive value.
The rule-based system does not perform well than the
neural networks. The most adequate results were obtained with the hybrid system.
Artificial Neural Network models can be used to analyze and predict results much
faster for clinical purposes, as it can completely mimic human brain. When
Network is trained well it can replace many human functions.
xii
3. References
www.mathworks.com
https://www.youtube.com/watch?v=RqAa8Uu9zbQ
https://en.wikipedia.org/wiki/Self-organizing_map#Applications
xiii