Select matrix for training,testing and validation on ANN

2 ビュー (過去 30 日間)
Tiago Dias
Tiago Dias 2019 年 11 月 29 日
編集済み: Tiago Dias 2019 年 12 月 4 日
Hello to all,
completeX = [1:+1:100;2:+2:200]';
completeY = [1:+1:100]';
From my data set i divided in a specific form and I got a Xtrain (72x2), Xcv (8x2) and Xtest (20x2)
i would like to tell the net which matrix is the training, validation and testing, instead of matlab performing the random spliting, is that possible?
net = fitnet(10,'trainlm');
net.divideParam.train = Xtrain;
net.divideParam.val = Xcv;
net.divideParam.test = Xtest;
[net, TR] = train(net,completeX',completeY');
Hope it was clear,
Thanks!

採用された回答

Raunak Gupta
Raunak Gupta 2019 年 12 月 4 日
Hi,
You may try dividing the whole dataset based on the indices as understandable from the question. Below code may help.
completeX = [1:+1:100;2:+2:200]';
completeY = [1:+1:100]';
net = fitnet(10,'trainlm');
net.divideFcn = 'divideind';
net.divideParam.trainInd = 1:72;
net.divideParam.valInd = 73:80;
net.divideParam.testInd = 81:100;
[net, TR] = train(net,completeX',completeY');
TR.trainInd , TR.valInd , TR.testInd will give the indices of training , validation and test data which can be used to find performance of the network. You may manipulate above indices vector as required.
  1 件のコメント
Tiago Dias
Tiago Dias 2019 年 12 月 4 日
編集済み: Tiago Dias 2019 年 12 月 4 日
Thanks, but i did a workaround.
I forced the validation and testing to be zero. So that i could use the train function only for the training set, then i validate with the testing set, in order to choose the right number of neurons for the hidden layer. Then i tested with the testing set.
What you wrote it was a good idea as well. since I got the 3 matrixes, i could merge them, and in that matter the first rows are training, then validation and testing, didnt think of that thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by