You are on page 1of 2

clc;clear all; close all;

Ve_null=[1 8 17 0 0.2 9 17 0 0.1 10 18 2 0.2;


2 12 20 4 0 12 20 5 0.1 14 21 6 0;
2 12 21 4 0.2 14 22 7 0.1 13 20 6 0.1;
2 13 21 5 0.1 12 21 5 0 15 23 7 0;
4 16 25 8 0.2 17 24 10 0 17 26 8 0;
4 17 25 10 0.2 18 27 10 0.1 20 28 12 0.2;
5 19 28 11 0.2 19 27 11 0.6 19 28 10 0;
5 21 30 13 0 21 29 13 0 21 29 13 0.4;
10 17 25 9 0.1 16 23 9 0.5 16 23 8 0.2;
11 15 23 7 0.1 15 23 7 1.1 14 21 7 0.7;
11 11 18 4 0.3 11 19 3 1 11 18 4 0.8;
12 9 16 2 0.1 8 15 2 0 10 17 3 0.3;
12 8 16 0 0 10 17 2 0 9 17 2 0;];
Vec_Ligeras=[
1 9 15 4 0 8 15 1 0 8 16 1 0.5;
1 9 16 1 0 8 15 1 0.4 9 17 1 0.3;
1 10 18 2 0.2 9 17 1 0.3 9 17 2 0;
2 8 15 1 0.2 9 16 1 0.7 8 15 1 0.7;
3 12 20 3 0 14 22 6 0.1 12 20 4 0;
3 13 21 5 0 13 20 6 0.3 14 22 6 0.3;
3 15 22 7 0.2 15 22 7 0 15 22 7 0;
3 16 25 7 0.2 16 25 7 0.2 16 24 8 0.1;
4 18 26 10 0 18 26 9 0 18 27 9 0;;
4 20 28 12 0.2 20 29 11 0 20 29 11 0;
5 22 31 14 0 21 30 13 0 22 31 13 0;
5 23 32 14 2.2 23 32 14 1.2 23 31 15 0.3;
6 25 33 17 0.6 25 33 16 0.7 26 33 18 0.1;
6 26 33 18 0.3 25 33 18 0.3 25 33 17 1;
6 26 33 19 2.4 25 33 18 0.9 26 32 19 1.5;
7 24 29 19 4.4 24 29 18 3.5 24 31 18 3;
8 23 29 18 1.7 23 29 18 5 24 29 18 2.9;
8 23 29 17 1.4 23 28 18 1.1 23 29 18 1.2;
9 20 27 14 2.6 21 28 14 0.5 21 27 14 0.3;
9 21 27 16 2.9 23 29 17 1.4 23 29 16 1.3;
10 20 27 13 1.7 21 29 13 0.5 22 29 15 0.1;
10 20 27 12 0.1 20 27 12 0.6 19 26 12 0.2;
11 15 23 8 0 16 23 8 0 15 22 7 0.1;
11 13 19 6 2 12 19 5 1.7 12 20 5 0;
12 11 19 3 0.5 11 19 3 0.1 12 19 4 0;
12 7 15 0 0.2 8 15 0 0.4 9 16 2 0.1;];
Vec_Moderadas=[
6 27 33 20 0.4 25 32 18 1.2 25 32 18 1.5;
7 25 31 19 2.8 24 29 19 4.4 25 30 19 1.2;
7 26 31 20 3.5 25 30 19 2.5 24 30 18 3.2;
7 25 30 19 5 24 30 19 4 24 29 18 4.2;
8 24 29 18 3.4 24 29 18 2.1 24 29 19 2.4;
8 24 29 19 2 24 29 18 4.6 23 29 17 2.3;
9 22 28 17 3.5 22 28 16 2.4 22 28 16 0.6;
9 21 28 15 2.5 21 27 15 1.4 21 27 15 1;
10 21 28 14 0.6 20 27 13 0.8 19 25 12 3.3;];

% se crean los targets que tengan la mism dimension de la matriz


for j=1:13
T_Null(:,j)=[1,0,0];
end
for j=1:26
T_Ligeras(:,j)=[0,1,0];
end
for j=1:9
T_Moderadas(:,j)=[0,0,1];
end
input=[Vec_null'Vec_Ligeras'Vec_Moderadas']; %darle la forma de una red neronal
vertical
targets=(T_Null T_Ligeras T_Moderadas];
%%
%% cre red neunoal pattennnet
red=patternnet(5, 'trainlm'); %crea red neuronal
red.trainParam.epochs=(1000); %Numero de epocas maximas
red.trainParam.max_fail=100; % verifica minimo locales posibles
red.trainParam.min_grad=1e-29;%error maximo permitido
red.trainParam.nu=0.1; %factor de aprendizaje
red.trainParam.nu_dec=10; %factor de aprendizaje creciente
red.trainParam.nu_inc=10; %factor de aprendizaje creciente
%red.layers(1).transferFcn='tansig';
%red.layers(2).transferFcn='tansig';
%cambiar la funcion de activacion de las neuronas de la capa 2
configure(red,input,targets);
%dividir el set de entrenamiento
red.divideParam.trainRatio=90/100;
red.divideParam.valRatio=5/100;
red.divideParam.testRatio=5/100;
%linea en la que ocurre el entrenamiento
[red,tr]=train(red, input,targets);

You might also like