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
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File 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!