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!