Hello everyone !
I would like to set the initial weights of artificial neural network in order to define relevant number of hidden nodes. So, I wrote the code below but it does not work. Could you correct it for me? Thank you.
function [performance] = NN(x,t,i)
[xn,xs] = mapminmax(x);
[tn,ts] = mapminmax(t);
trainFcn = 'trainlm';
H = i ;
net = fitnet(H, trainFcn);
I = size(x,1);
N = size(x,2);
O = size(t,1);
net = configure(net, xn, tn);
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'logsig';
rng(0);
IW = 0.001 * randn(H,I);
LW = 0.001 * randn(O,H);
b1 = 0.001 * randn(H,1);
b2 = 0.001 * randn(O,1);
net.IW{1,1}
net.LW{2,1}
net.b{1}
net.b{2}
net.divideFcn = 'dividerand';
[net] = train(net,xn,tn);
net.IW{1,1} = IW;
net.LW{2,1} = LW;
net.b{1} = b1;
net.b{2} = b2;
y = net(xn);
e = gsubtract(tn,y);
performance = perform(net,tn,y)