Kohonen ejemplo

Solo disponible en BuenasTareas
  • Páginas : 7 (1643 palabras )
  • Descarga(s) : 0
  • Publicado : 31 de mayo de 2011
Leer documento completo
Vista previa del texto
Red de Kohonen
Éste es un pequeño ejemplo de la red de Kohonen.
Contents
• Patrones de entrenamiento
• Red de Kohonen
• Entrenamiento
• Caso patológico sin conciencia
• Entrenamiento de caso patológico sin conciencia
• Caso patológico con conciencia
• Entrenamiento de caso patológico con conciencia
Patrones de entrenamiento
Éstos son los patrones deentrenamiento.
X = [8 0; 10 2;10 11;12 9;2 7;6 7];
p = X';
Red de Kohonen
La red de Kohonen se crea con la función newc. Fijamos la constante de aprendizaje en 0.01 y la constante de conciencia en 0.001 (estos son los defaults). Podemos ver que los pesos fueron inicializados al punto medio de los rangos de cada entrada.
red1 = newc([2 12;0 9],3,0.01,0.00);
w = red1.IW{1,1};plot(w(:,1),w(:,2),'xr',p(1,:),p(2,:),'o')
axis([min(p(1,:))-1 max(p(1,:))+1 min(p(2,:))-1 max(p(2,:))+1])
xlabel('x1')
ylabel('x2')
title('Red de Kohonen')
legend('pesos','patrones','location','NorthWest')
[pic]
Entrenamiento
La red se entrena con la función train. En este ejemplo, graficamos los pesos de la red después de cada 10 épocas.
red1 = init(red1);
red1.trainParam.epochs = 10;
for i=1:25red1 = train(red1,p);
w = red1.IW{1,1};
plot(w(:,1),w(:,2),'xr',p(1,:),p(2,:),'o')
axis([min(p(1,:))-1 max(p(1,:))+1 min(p(2,:))-1 max(p(2,:))+1])
xlabel('x1')
ylabel('x2')
title('Red de Kohonen')
legend('pesos','patrones','location','NorthWest')
pause(0.1)
end
w
a = sim(red1,p);
ac = vec2ind(a);
[X ac']
TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR,Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR,Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR,Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

TRAINR, Epoch 0/10
TRAINR, Epoch 10/10
TRAINR, Maximum epoch reached.

w =

10.9890 9.9207
9.0717 1.1068
4.3069 6.9468

ans =

8 0 2
10 2 2
10 11 1
12 9 1
2 73
6 7 3

[pic]
Caso patológico sin conciencia
Mostramos la necesidad de conciencia inicializando los pesos a valores "patológicos", y creamos una red sin conciencia.
red1 = newc([0 4;-1 1],3,0.01,0.00);
w = red1.IW{1,1}
plot(w(:,1),w(:,2),'xr',p(1,:),p(2,:),'o')
axis([min(p(1,:))-1 max(p(1,:))+1 min(p(2,:))-1 max(p(2,:))+1])
xlabel('x1')
ylabel('x2')
title('Red de...
tracking img