Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How to run neural network with dividing data to 2sets instead of 3 sets ?

1 Ansicht (letzte 30 Tage)
Rita
Rita am 17 Nov. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I know that in R software (neuralnet package) the datasets divides to two set of training and test sets I was wondering if there is a possibility to run the neural network with two sets of data similar to neuralnet?I would appreciate if someone could correct this script of applying ANN with two sets of data....Thanks
% if I have trainX and trainY as trainSet data and testX and testY as
% testSet.AS I want to train the model with trainSet and test the model with the
%testSet
inputs = trainX';
targets = trainY';
net = newfit(trainX(:,ind)', trainY', 17);
net.performFcn = 'mse';
net = train(net, trainX(:,ind)', trainY');
hiddenLayerSize = 5;
for i = 1:30 % to repeat for 30 times with different initial weights
net = fitnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
[net,tr] = train(net,trainX',trainY');
outputs = net(testX');
errors = gsubtract(testY',outputs);
performance = perform(net,testY',outputs);% Iam not sure if it is correct
save(net)
end
  1 Kommentar
Rita
Rita am 18 Nov. 2016
Thanks Walter,I have copied my script would you mind correcting this?Thanks

Antworten (1)

Walter Roberson
Walter Roberson am 17 Nov. 2016
  1 Kommentar
Walter Roberson
Walter Roberson am 18 Nov. 2016
Before the train() call,
trainfrac = 0.8;
net.divideParam.trainRatio = trainfrac;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 1-trainfrac;

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by