Feed Forward ANN Training using Back Propagation
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Shaik
2023-5-13
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 个评论
John D'Errico
2023-5-31
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!