MATLAB Answers

Does "train" already include train/val/test division if a feedforward neural network or should I do it manually before?

11 ビュー (過去 30 日間)
Tommaso Di Noto
Tommaso Di Noto 2017 年 9 月 8 日
コメント済み: Greg Heath 2017 年 9 月 14 日
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');
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:
Thank you for your time!

回答 (2 件)

Greg Heath
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
[ 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

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
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


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by