Feed Forward ANN Training using Back Propagation

1 view (last 30 days)
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.

Answers (1)

Shaik on 13 May 2023
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;
% Display the results
disp(['Final weights: ' num2str(w')]);
Final weights: 1.4659 -0.55741 1.9576
disp(['Final bias: ' num2str(b)]);
Final bias: 1.0003
disp(['Final output: ' num2str(y)]);
Final output: 0.99854
Warren on 7 Jun 2023
Well, dear, let's talk in general first. When I came to the site, I did not expect that I would get help because these questions are within artificial intelligence, while the brother helped me, and I am grateful for his efforts, but such questions are external and not among the sources of methodology (the purpose of human life is to help others) if you You cannot help others, at least try to be generous with your silence, because you are annoying when you act selfishly. All sites are also unable to solve it, because it is not within any source .. The goal was humanitarian assistance, but I do not know where the mistake is in that. I have benefited a lot .. and not least the site It is useful when the questions are within Matlab, ideas and new development, while when searching for such a question, one will resort to the site. I hope from the bottom of my heart that it will change for the better and cancel this selfishness. Thank you very much.

Sign in to comment.



Community Treasure Hunt

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

Start Hunting!