Validation set in a NARX network

4 次查看(过去 30 天)
Francesco
Francesco 2022-11-9
回答: Neha 2023-8-29
I am using a NARX neural network to estimate a variable from 20 different signals recorded by sensors. I have N different recordings of equal length T. The data are prepared using the preparets function as follows:
[Xs,Xi,Ai,Ts] = preparets(net,Xdata,{},Ydata);
Xdata is a cell array 1xT, and each cell is a matrix 20xN. Ydata is a cell array 1xT, and each cell is a array 1xN.
I am doing the training using the following line
[net,tr] = train(net,Xs,Ts,Xi,Ai)
I would like to make a validation set using a sub-set of recordings to perform early stopping during training. So far, when I enable the validation (e.g. net.divideFcn = 'dividerand'), the validation set is created using time samples from all recordings in the training. I would like to separate specific recordings (let's say the 20% of N) to perform validation during training.
Thanks!

回答(1 个)

Neha
Neha 2023-8-29
Hi Francesco,
I understand that you want to train a NARX neural network and include a subset of recordings for validation. You can refer to the following code to create a validation set with 20% of the recordings:
net = narxnet(1:2,1:2,10);
net.divideMode = 'sample';
net.divideFcn = 'divideind'; % Use individual indices for division
net.divideParam.trainInd = 1:80;
net.divideParam.valInd = 80:100;
[Xs,Xi,Ai,Ts] = preparets(net,Xdata,{},Ydata);
[net,tr] = train(net,Xs,Ts,Xi,Ai)
Hope this helps!

类别

Help CenterFile 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!

Translated by