Neural network (fitnet) and data decomposition?

8 visualizaciones (últimos 30 días)
coqui
coqui el 17 de En. de 2016
Respondida: CH PH el 31 de En. de 2021
Can you help me to rectify these code, I used fitnet to predict future index. I need to decompose the data only to training and test:
inputs = P';
targets = T';
% Create a Fitting Network
net = fitnet(hiddenLayerSize);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'divideblock'; % Divide data into two block (the first 80% of data sample for train and the rest for test)
net.divideMode = 'sample';
% Divide up every sample
net.divideParam.trainRatio = 80/100;
% net.divideParam.valRatio = 0;
net.divideParam.testRatio = 20/100;
% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
MSEgoal = 0.001
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
% valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
% valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)

Respuesta aceptada

Greg Heath
Greg Heath el 22 de En. de 2016
The training and test indices are given in tr. Type, without semicolon
tr = tr
to see what info is in tr.
Hope this helps.
Thank you for formally accepting my answer
Greg

Más respuestas (1)

CH PH
CH PH el 31 de En. de 2021
no result

Community Treasure Hunt

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

Start Hunting!

Translated by