Feed Forward ANN Training using Back Propagation
1 view (last 30 days)
Show older comments
Find a new weights by using Matlab code, when shown below is presented the input pattern (1 2 3) and the target output is 1. Using learning rate of 0.2 and bipolar sigmoid activation function, the bias is set to1.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1381929/image.jpeg)
0 Comments
Answers (1)
Shaik
on 13 May 2023
Hi,
Hope this resolves your issue
% Define the input pattern and target output
x = [1; 2; 3];
t = 1;
% Define the initial weights
w = randn(3, 1);
% Define the learning rate and bias
alpha = 0.2;
b = 1;
% Define the activation function
sigmoid = @(x) 2./(1+exp(-x)) - 1;
% Initialize the error and iteration counter
err = inf;
iter = 0;
% Loop until the error is small enough or a maximum number of iterations is reached
while err > 0.01 && iter < 1000
% Calculate the net input
net = w' * x + b;
% Calculate the output of the neuron using the bipolar sigmoid activation function
y = sigmoid(net);
% Calculate the error
e = t - y;
% Update the weights and bias
dw = alpha * e * x;
w = w + dw;
db = alpha * e;
b = b + db;
% Calculate the squared error
err = e^2;
% Increment the iteration counter
iter = iter + 1;
end
% Display the results
disp(['Final weights: ' num2str(w')]);
disp(['Final bias: ' num2str(b)]);
disp(['Final output: ' num2str(y)]);
2 Comments
John D'Errico
on 31 May 2023
PLease don't do obvioius homework assignments for students who cannot bother to show an effort of their own. This does not help the student, as it teaches them nothing but that there is always someone willing to do their work for them. Why you want to do that, is up to you, but it is a bad idea for the student.
It does not help the site, because it teaches this student that they can now post addigntional questions, and get their homework assignment done for them.
It hurts the site because it also convinces other students they they too can spam the site with their homework assignments.
This was the third question this student posted, with no effort made. Do you expect them to learn anything more than to keep on posting their homework?
See Also
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!