Neural network (fitnet) and data decomposition?

4 vues (au cours des 30 derniers jours)
coqui
coqui le 17 Jan 2016
Réponse apportée : CH PH le 31 Jan 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)

Réponse acceptée

Greg Heath
Greg Heath le 22 Jan 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

Plus de réponses (1)

CH PH
CH PH le 31 Jan 2021
no result

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