Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to run neural network with dividing data to 2sets instead of 3 sets ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2016년 11월 17일
https://www.mathworks.com/help/nnet/ref/dividerand.html and give 0 as the validation ratio.
댓글 수: 1
Walter Roberson
2016년 11월 18일
Before the train() call,
trainfrac = 0.8;
net.divideParam.trainRatio = trainfrac;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 1-trainfrac;
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!