I have written a code for forward pass of neural network with the following inputs and targets as shown in the code below. A bias is also present and there is one hidden layer (with 2 neurons) and one output layer.
I am not sure whether the code I have written is correct. Could someone tell me if my logic is correct?
X = [0 0; 0 1];
D = [0;1];
X = [ones(1,2); X];
w1 = [0.15, 0.1, 0.3];
w2 = [-0.05, -0.2,-0.25];
w3 = [0.1,0.2, -0.3];
lr = 1;
H = 2;
No = 1;
max_iter = 10;
for iter = 1:max_iter
for j=1:H %Forward Pass
inpH1 = (w1*X);
outH1 = logsig(inpH1);
inpH2 = (w2*X);
outH2 = logsig(inpH2);
output = [ones(1,2); outH1; outH2];
end
for k=1:No
inpO = w3*output;
out_layer = logsig(inpO);
end
Error = 0.5*(D-out_layer').^2
end