简体   繁体   中英

Data Division in MATLAB Neural Network Train Command

While training a neural network in MATLAB I am using "train" command. Is this command auto divide the data into training, testing, and validation sets or we have to divide the data manually.

Yes, it does. But we can divide the data manually, if we want to. net.divideFcn and net.divideParam fields of the net object should be used:

t=0:0.05:8; x= sin(t);
net = feedforwardnet(3);
net.divideFcn= 'dividerand'; % divide the data randomly 
net.divideParam.trainRatio= 0.7; % we use 70% of the data for training 
net.divideParam.valRatio= 0.3; % 30% is for validation
net.divideParam.testRatio= 0; % 0% for testing
net = train(net,t,x);
plot(t,x,t,net(t));

Here is an example of a manual data division:

net.divideFcn= 'divideind'; % divide the data manually
net.divideParam.trainInd= 1:100; % training data indices 
net.divideParam.valInd= 101:140; % validation data indices 
net.divideParam.testInd= 141:161;  % testing data indices 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM