Ho to add activation function neuron?

1 vue (au cours des 30 derniers jours)
Nuraida Puspitasari
Nuraida Puspitasari le 4 Oct 2018
I am developing backpropagation Neural Network for classification, but I am confused how to determine the number of neurons in layer and the activation functions for each neuron? The input parameters are 9 and the output is 8
Scripts for training are as follows :
%clear; clc; close all; %%%
%This code to choose the .csv file as 'training input data' %clear; clc; [FileName,PathName] = uigetfile('.*','Select data as Training Input'); PD=csvread([PathName,FileName],1,11); % csv file from sensor PD=abs(PD);%% Absolute all Parameters of (.csv)
%%% This code to normalize all input parameters % Normalization of 9 Parameters(.csv) A=PD(:,1); %peak value normA = A - min(A(:)); %norm of peak value normA = normA ./ max(normA(:));
B=PD(:,6); %phase normB = B - min(B(:)); %norm of phase normB = normB ./ max(normB(:));
C=PD(:,11); %risetime normC = C - min(C(:)); %norm of risetime normC = normC ./ max(normC(:));
D=PD(:,12); %falltime normD = D - min(D(:)); %norm of falltime normD = normD ./ max(normD(:));
E=PD(:,13); %pulsewidth normE = E - min(E(:)); %pulsewidth normE = normE ./ max(normE(:));
F=PD(:,15); %pulsearea normF = F - min(F(:)); %pulsearea normF = normF ./ max(normF(:));
G=PD(:,16); %eventwidth normG = G - min(G(:)); %eventwidth normG = normG ./ max(normG(:));
H=PD(:,17); %freqofmaxampltd normH = H - min(H(:)); %freqofmaxampltd normH = normH ./ max(normH(:));
I=PD(:,19); %freqof1stmom normI = I - min(I(:)); %freqof1stmom normI = normI ./ max(normI(:));
normPD = table([normA],[normB],[normC],[normD],[normE],[normF],[normG],[normH],[normI]);
% this code to assign 'x' as a variable for training input normPD=table2array(normPD); x=normPD; x=x'; %transpose the training input %L=length(x); %count the number of rows 'x' %%%
%This code to choose the .csv file as 'target output data' [FileName,PathName] = uigetfile('.*','Select file as Target Output'); target_output_TEV=csvread([PathName,FileName],0,0); target_output_TEV=target_output_TEV'; %transpose the target output t=target_output_TEV; %%%
% Choose a Training Function trainFcn = 'trainbr'; % Bayesian Regularization
% Choose a Performance Function performFcn = 'mse'; % Mean-square error
% Create a Pattern Recognition Network hiddenLayerSize = 13; net9_tev2d = patternnet(hiddenLayerSize,trainFcn, performFcn);
% Setup Division of Data for Training, Validation, Testing % For a list of all data division functions type: help nndivide RandStream.setGlobalStream(RandStream('mt19937ar','seed',1)); % to get constant result net9_tev2d.divideFcn = 'dividerand'; % Divide data randomly net9_tev2d.divideMode = 'sample'; % Divide up every sample net9_tev2d.divideParam.trainRatio = 70/100; net9_tev2d.divideParam.valRatio = 15/100; net9_tev2d.divideParam.testRatio = 15/100;
%Training Parameters net9_tev2d.trainParam.show=50; %# of ephocs in display net9_tev2d.trainParam.lr=0.05; %learning rate net9_tev2d.trainParam.epochs=1000; %max epochs net9_tev2d.trainParam.goal=0.01^2; %training goal net9_tev2d.efficiency.memoryReduction=100; net9_tev2d.trainParam.max_fail=1000;%maximum validation fail net9_tev2d.trainParam.min_grad=1e-5;
% Choose a Performance Function % For a list of all performance functions type: help nnperformance net9_tev2d.performFcn = 'mse'; % Mean-square error
% Choose Plot Functions % For a list of all plot functions type: help nnplot net9_tev2d.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotconfusion', 'plotroc'};
% Train the Network [net9_tev2d,tr] = train(net9_tev2d,x,t);
% Test the Network y = net9_tev2d(x); e = gsubtract(t,y); performance = perform(net9_tev2d,t,y) tind = vec2ind(t); yind = vec2ind(y); percentErrors = sum(tind ~= yind)/numel(tind);
% Recalculate Training, Validation and Test Performance trainTargets = t .* tr.trainMask{1}; valTargets = t .* tr.valMask{1}; testTargets = t .* tr.testMask{1}; trainPerformance = perform(net9_tev2d,trainTargets,y) valPerformance = perform(net9_tev2d,valTargets,y) testPerformance = perform(net9_tev2d,testTargets,y)
% Plots figure, plotconfusion(t,y)
Than you so much for the help.

Réponse acceptée

Greg Heath
Greg Heath le 4 Oct 2018
Search the NEWSGROUP AND ANSWERS using
greg patternnet
Hope this helps.
Thank you for formally accepting my answer
Greg

Plus de réponses (0)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by