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!