How I can Pass The same training, validation and test data to different neural nets?

I want to train two networks with the taining, validation and testing data
I'm trying to overwrite net.divideParam.trainInd, net.divideParam.valInd, net.divideParam.testInd
I have the following error: 'trainInd' is not a legal parameter.
Data = load('Data.txt');
Train = num2cell(Data');
Delay = 4; Neurons = 20;
trainRatio = 0.8; valRatio = 0.10; testRatio = 0.10;
[trainInd,valInd,testInd] = dividerand(length(Data),trainRatio,valRatio,testRatio);
%======================
% NAR 1
%======================
net1 = narnet(1:Delay,Neurons);
X1 = Train;
[Xs1,Xi1,Ai1,Ts1] = preparets(net1,{},{},X1);
net1.divideParam.trainInd = trainInd;
net1.divideParam.valInd = valInd;
net1.divideParam.testInd = testInd;
net1 = train(net1,Xs1,Ts1,Xi1,Ai1);
%======================
% NAR 2
%======================
net2 = narnet(1:Delay,Neurons);
X2 = Train;
[Xs2,Xi2,Ai2,Ts2] = preparets(net2,{},{},X2);
net2.divideParam.trainInd = trainInd;
net2.divideParam.valInd = valInd;
net2.divideParam.testInd = testInd;
net2 = train(net2,Xs2,Ts2,Xi2,Ai2);

Asked:

on 30 Aug 2019

Answered:

on 31 Aug 2019

Community Treasure Hunt

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

Start Hunting!