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.

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)]);
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!