Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How to run neural network with dividing data to 2sets instead of 3 sets ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Respuestas (1)
Walter Roberson
el 17 de Nov. de 2016
https://www.mathworks.com/help/nnet/ref/dividerand.html and give 0 as the validation ratio.
1 comentario
Walter Roberson
el 18 de Nov. de 2016
Before the train() call,
trainfrac = 0.8;
net.divideParam.trainRatio = trainfrac;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 1-trainfrac;
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!