Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

How can I derive the output based upon the weights and biases from the neural network?

1 view (last 30 days)
I have a simple neural network with 7 inputs, 1 hidden layer with two neurons and 1 output. I got the weights and biases after training the network. Tried to derive the output using the following steps and got results very different from net(x'): b1 = net.b{1}; iw11 = net.iw{1}(1,:); iw12 = net.iw{1}(2,:); b2 = net.b{2}; lw = net.lw{2};
Theta1 =[b1(:,1),iw11;b1(:,2),iw12]; Theta2 =[b2,lw];
X = [ones(m,1),x]; % x is the input matrix of 38x7 a1 = Theta1 * X'; z1 = tansig(a1); % tansig transfer function tansig(n) = 2/(1+exp(-2*n))-1 z1 = [ones(1,38);z1]; % z2 = Theta2 * z1; output = z2;
Could you please let me know why? Below are the details of the definition of the network and source data (x: input, t: output) is attached:
net = fitnet(2); net.divideFcn = 'dividerand'; % Divide data randomly net.divideMode = 'sample'; % Divide up every sample net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
[net,tr] = train(net,x',t');
Thanks!

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!