Neural network (fitnet) and data decomposition?

조회 수: 4 (최근 30일)
coqui
coqui 2016년 1월 17일
답변: CH PH 2021년 1월 31일
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