Académique Documents
Professionnel Documents
Culture Documents
DEPARTAMENTO ELECTRICA
Y ELECTRONICA
CONTROL INTELIGENTE
PRIMER PARCIAL
Actividad 5 y 6
DESARROLLO ACTIVIDADES 5 Y 6
28 de octubre de 2015
PRIMER PARCIAL
Actividad 5 y 6
Indice
1. Actividad 5
1.1. Apartado 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2. Apartado 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2. Actividad 6
2.1. Apartado
2.2. Apartado
2.3. Apartado
2.4. Apartado
1
2
3
4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
2
3
5
5
6
9
12
PRIMER PARCIAL
Actividad 5 y 6
1
SECCION
1.1.
Apartado 6
wi =
wi
1
= (targ out)2
2
out = sigmoid(net)
net =
n
X
ini wi
i=0
out net
wi = (
)
out net wi
wi = [(targ out) (1) out (1 out) ini ]
wi = [(targ out) out (1 out) ini ]
w0 = [(targ out) out (1 out) in0 ]
w1 = [(targ out) out (1 out) in1 ]
w2 = [(targ out) out (1 out) in2 ]
Actividad 5
PRIMER PARCIAL
Apartado 7
Modifique el programa de la regla de aprendizaje para que ejecute el entrenamiento por descenso de gradiente. Transcriba el programa y el gr
afico correspondiente.
El programa desarrollado en Matlab es el siguiente
%asignaci
on de pesos aleatorios
w0=rand();
w1=rand();
w2=rand();
in0=1;
alfa=1;
n=0.8; %factor de aprendizaje
inputs=[1 0.1;2 0.2;0.1 0.3;2 0.3; 2 0.3; 0.2 0.4;3 0.4;
0.1 0.5;1.5 0.5;0.5 0.5;1.6 0.7]
target=[1 1 0 1 0 1 0 1 0 0]; %salidas deseadas
for j=1:50 %n
umero de
epocas
err_t=0;
for i=1:10
net=(inputs(i,1)*w1+inputs(i,2)*w2+in0*w0);
out=1/(1+exp(-alfa*net)); % funci
on sigmoide
Delta_w0=n*(target(i)-out)*in0*alfa*out*(1-out);
Delta_w1=n*(target(i)-out)*inputs(i,1)*alfa*out*(1-out);
Delta_w2=n*(target(i)-out)*inputs(i,2)*alfa*out*(1-out);
%Actualizaci
on de pesos
w0=w0+Delta_w0;
w1=w1+Delta_w1;
w2=w2+Delta_w2;
err_i=1/2*(target(i)-out)^2;
err_t=err_t+err_i;
end
vector_epoca(j)=j;
vector_error(j)=err_t;
plot(vector_epoca,vector_error);
grid on
title(Aprendizaje de un perceptr
on por descenso de gradiente)
3
1.2.
Actividad 5 y 6
PRIMER PARCIAL
Actividad 5 y 6
xlabel(Epocas)
ylabel(Error cuadr
atico)
end
%Pesos finales
w0
w1
w2
Los pesos obtenidos son los siguientes:
w0 = 0.9879
w1 = -0.7583
w2 = -1.4825
En la grafica se puede observar que mientras aumenta el numero de epocas el error medio
cuadratico disminuye, tambien se observa que la curva del entrenamiento por gradiente es mas
suave que la curva de la primera regla de aprendizaje.
4
PRIMER PARCIAL
Actividad 5 y 6
2
SECCION
2.1.
Apartado 1
1
1 + ex
f (x)
=
ex
x
(1 + ex )2
Se separa la expresion anterior y para no afectar la primera ecuacion se resta y se suma el
termino 1 en la parte de la expresion teniendo como resultado la siguiente ecuacion
1
1 1 + ex
f (x)
=
x
(1 + ex ) (1 + ex )
Se separa la expresion nuevamente teniendo lo siguiente:
f (x)
1
1 + ex
1
=
(
)
x
x
x
(1 + e ) (1 + e ) (1 + ex )
Como resultado se obtiene la siguiente ecuacion
f (x)
= f 0 (x) = f (x) (1 f (x))
x
Actividad 6
PRIMER PARCIAL
Apartado 2
2.2.
Actividad 5 y 6
PRIMER PARCIAL
xlabel(in)
ylabel(out)
grid on
hold on
w1=1;
x=in*w1+in0*w0;
out=1./(1+exp(-x));
plot(in,out,g)
xlabel(in)
ylabel(out)
w1=0;
x=in*w1+in0*w0;
out=1./(1+exp(-x));
plot(in,out,r)
xlabel(in)
ylabel(out)
w1=2;
x=in*w1+in0*w0;
out=1./(1+exp(-x));
plot(in,out,k)
xlabel(in)
ylabel(out)
legend(w0=0, w1=-1,w0=0, w1=1,w0=0, w1=0,w0=0, w1=2)
a) w0=0; w1=1
Actividad 5 y 6
PRIMER PARCIAL
Actividad 5 y 6
b) w0=0; w1=-1
PRIMER PARCIAL
Apartado 3
2.3.
Actividad 5 y 6
PRIMER PARCIAL
1.png
Actividad 5 y 6
PRIMER PARCIAL
Actividad 5 y 6
x=in*w1+in0*w0;
out=1./(1+exp(-x));
plot(in,out)
w0=4
w1=0.3
x=in*w1+in0*w0;
out=1./(1+exp(-x));
plot(in,out,r)
hold off
title(Funci
on de out/in)
xlabel(Entrada )
ylabel(Salida)
Grafica de la funci
on de out/in
11
PRIMER PARCIAL
Apartado 4
Resuma los efectos combinados que produce el ajuste de los pesos w0 y w1 durante
el aprendizaje
Durante el aprendizaje los efectos de modificar los pesos w0 y w1 :
Ajustar el peso w0 ajusta los puntos de frontera
Para un valor de w0 positivo el punto de frontera se desplaza a la izquierda
Para un valor de w0 negativo el punto de frontera se desplaza a la derecha.
12
2.4.
Actividad 5 y 6
PRIMER PARCIAL
13
Actividad 5 y 6