Training neural network - Forward Pass

4 次查看(过去 30 天)
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

回答(1 个)

Greg Heath
Greg Heath 2019-4-3
You are very mixed up. I suggest going to the library and finding a good elementary NN book.
Obviously, the appropriate info is available online. However, you will have to search and/or get help from elsewhere.
Sorry,
Greg

类别

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