how to use two separate files for ANN?
이전 댓글 표시
Hi, I would like to use two separate files for ANN.one file for training and the other file for test of data.Here is for the one input.
inputs = ii';
targets = f';
inputGap = ig;
targetGap = fg;
hiddenLayerSize = j;
net = fitnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand';
net.divideMode = 'sample';
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
% Train the Network
[net,tr] = train(net,inputs,targets);
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
valTargets = targets .* tr.valMask{1};
testTargets = target .* tr.testMask;
trainPerformance = perform(net,trainTagets,outputs);
testPerformance = perform(net,testTargets,outputs);
out1.net = net;
out1.inputs = inputs;
out1.targets = targets;
댓글 수: 1
Greg Heath
2015년 8월 17일
Insufficient information as to what you want to do.
Meanwhile
GEH1. What is the purpose of inputGap?
GEH2. Sizes of inputs and targets?
GEH3. Why 4 <= H <= 19?
GEH4: Why not initialize/store RNG(i,j) = rng for reproducibility?
GEH5. Why waste space with 9 fitnet default assignments?
GEH6. Can include outputs and errors in the output of train
GEH7: Why no 30x16 (i,j) summary of all that work?
GEH8: Why 0.7 for TestReg threshold? Corresponds to
a Rsquare of only sqrt(0.7) = 0.8367
채택된 답변
추가 답변 (1개)
Walter Roberson
2015년 8월 17일
1 개 추천
Instead of using 'dividerand' use dividind; see http://www.mathworks.com/help/nnet/ug/divide-data-for-optimal-neural-network-training.html for the divideParam field names to use.
The "inputs" would be the concatenation of the two files's data, and the "targets" would be the concatenation of the respective targets, and the ind for the training would be 1 : numberoftraining with the ind for test being ((1:numberoftest) + numberoftraining)
댓글 수: 1
Greg Heath
2015년 8월 18일
편집: Greg Heath
2015년 8월 18일
Replace numberoftraining with numberofdesign where
numberofdesign = numberoftraining + numberofvalidation
This can also be implemented using divideblock
Hope this helps.
Greg
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!