0% found this document useful (0 votes)
10 views3 pages

Perceptron Training in MATLAB Code

The document discusses neural network training using MATLAB. It contains examples of perceptron and multi-layer neural network training on various datasets using different training functions such as gradient descent, BFGS, Levenberg-Marquardt.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Perceptron Training in MATLAB Code

The document discusses neural network training using MATLAB. It contains examples of perceptron and multi-layer neural network training on various datasets using different training functions such as gradient descent, BFGS, Levenberg-Marquardt.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Costos

Ingeniera econmica

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PROBLEMA SIMPLE DE CLASIFICACION DE UN PERCEPTRON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
P=[0.1 0.7 0.8 0.8 1.0 0.3 0.0 -0.3 -0.5 -1.5;
1.2 1.8 1.6 0.6 0.8 0.5 0.2 0.8 -1.5 -1.3];
T=[1 1 1 0 0 1 1 1 0 0;
0 0 0 0 0 1 1 1 1 1];
%Creaccion de la estructura de la red
net=newp([-2 2;-2 2],2,'hardlim','learnp');

%Entrenamiento de la red
[Link]=100;
[Link]=0;
[Link]=1;
net=train(net,P,T);

%Simulacion de salida
Y=sim(net,P)

% Representacin de los datos


plotpv(P,T);
plotpc([Link]{1,1},net.b{1});

% Realice una nueva red para los siguientes datos


%Nuevos datos
P=[-0.5 -0.5 0.3 -0.1 -0.8;
-0.5 0.5 -0.5 1.0 0.0];
T=[1 1 0 0 0];

%Creaccion de la estructura de la red


net=newp([-2 2;-2 2],1,'hardlim','learnp');

%Entrenamiento de la red
[Link]=100;
[Link]=0;
[Link]=1;
net=train(net,P,T);

%Simulacion de salida
Y=sim(net,P)

% Representacin de los datos


plotpv(P,T);
plotpc([Link]{1,1},net.b{1});
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% APROXIMACIN DE FUNCIONES CON REDES MULTICAPA TANSIG/PURELIN
% Entrenamiento mediante descenso por el gradiente
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all;
% DEFINICIN DE LOS VECTORES DE ENTRADA-SALIDA
% ============================================

P = -1:.1:1;
T = [-.9602 -.5770 -.0729 .3771 .6405 .6600 .4609 ...
.1336 -.2013 -.4344 -.5000 -.3930 -.1647 .0988 ...
.3072 .3960 .3449 .1816 -.0312 -.2189 -.3201];

plot(P,T,'+');
title('Vectores de entrenamiento');
xlabel('Vector de entrada P');
ylabel('Vector Target T');

% DISEO DE LA RED
% ==================

net = newff([-1 1],[5 1],{'tansig' 'purelin'}); %[0 1] margenes maximos


de la entrada,
net=init(net); %[5 1]
neuronas de la capa oculta y salida
%{'tansig' 'purelin'} tipo
de funciones usadas

[Link] = 4000;
[Link] = 10;
[Link] = 0.001;
[Link] = 0.01;
net = train(net,P,T);
Y=sim(net,P);
plot(P,T,'+'); hold on;
plot(P,Y,'-r'); hold off;
title('Vectores de entrenamiento');
xlabel('Vector de entrada P');
ylabel('Vector Target T');

%Otros metodos de aprendizaje

[Link]= 'trainbfg'; %Backpropagation BFGS quasi-Newton


[Link]= 'traincgb'; %Backpropagation con gradiente Powell-Beale
[Link]= 'traincgf'; %Backpropagation con gradiente Fletcher-Powell
[Link]= 'traincgp'; %Backpropagation con gradiente Polak-Ribiere
[Link]= 'traingd'; %Backpropagation con descenso por el gradiente
(por defecto)
[Link]= 'traingda'; %Backpropagation con descenso por el gradiente
con ratio de aprendizaje adaptativo
[Link]= 'traingdm'; %Backpropagation con descenso por el gradiente
con momento.
[Link]= 'traingdx'; %Backpropagation con descenso por el gradiente
con momento y ratio de aprendizaje adaptativo.
[Link]= 'trainlm'; %Backpropagation Levenberg-Marquardt.
[Link]= 'trainoss'; %one step secant backpropagation
[Link]= 'trainscg'; %Backpropagation con gradiente escalado.

You might also like