Does "train" already include train/val/test division if a feedforward neural network or should I do it manually before?
6 次查看(过去 30 天)
显示 更早的评论
Hello everyone! I have the following script:
-----------------------
inputs=training_set'; %training_set is my matrix of features, with observation on rows and features on columns
net = feedforwardnet(10); %I set 10 hidden layers and by default trains with "trainlm" function
[net,tr] = train(net,inputs,new_training_labels');
y_predict=net(inputs);
----------------------
My question is: does train already divide "inputs" in train/val/test and runs the crossvalidation automatically or should I do it before and then write something like:
y_predict=net(inputs(trainInd,:));
Thank you for your time!
0 个评论
回答(2 个)
Greg Heath
2017-9-13
1. Use fitnet for regression and patternnet for classification.
2. Use the help and doc commands for sample code.
3. Run the sample code. If you have problems, here we are!
4. Adjust your code until you are satisfied.
5. Try your data with the code
etc
[ net tr y e ] = train( net, x, t );
% y = net(x); e = t-y;
NMSE = mse(e)/mse(t-mean(t,2)) % NORMALIZED MSE
All of the datadivision details are in the training record tr
To watch all of the goodies tumble out just type
tr = tr
Hope this helps.
Thank you for formally accepting my answer
Greg
0 个评论
Helper
2017-9-13
Yes, it already includes train, validation, and test.
The default training function of “feedforwardnet” is “trainlm”. If you check the documentation of “ trainlm ”.
You will find “trainlm supports training with validation and test vectors if the network's NET.divideFcn property is set to a data division function.” Then if you check the “divideFcn” of “net” in your case, it would be “dividerand” (in MATLAB R2017a).
For more information of “dividerand”, please type “help nndivision”, then you would get a more detailed explanation.
1 个评论
Greg Heath
2017-9-14
For more information on any entity FIRST use the help and doc commands (in that order!). The recent versions of the doc commands are not as helpful as the older versions.
help dividerand
doc dividerand
Hope this helps
Greg
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!