Neural network (fitnet) and data decomposition?

5 次查看(过去 30 天)
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)

采纳的回答

Greg Heath
Greg Heath 2016-1-22
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

更多回答(1 个)

CH PH
CH PH 2021-1-31
no result

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by