Updated 3 Jun 2014
We had to choose two hidden layers, one input layer and one output layer and we had to use the training set of following form:
Here we use different values of learning cofficient(Ƞ) , number of neurons(n) in the hidden layer and number of steps(N) and observe the results.
N= 10, 15, 20
Ƞ= 0.1, 0.5, 0.9
N= 10, 15, 20
This was achieved by using back propogation algorithm. Number of neurons in the hidden layer were varied depending upon te requirements and in the outter layer a single neuron was implemented.
There are two inputs. One of them is the value of xi which is actually the input of the function h(x). Second one is for threshold, which is always -1. Now the weight(extended) matrix depend upon the number of neurons used in the hidden layer. Weight(extended) matrix is nx2, where n is the number of neurons and the 2nd column is for threshold vector. Random weights were initialized ranging from -4 to +4. The input multiplies with the weight and then goes through the non linear function which is given as:
After passing through this function the output of this non linear function goes to the single neuron of the output layer which gives an output. This output is passed through the similar non linear function and is compared with the desired output h(x(i)). This gives us error. By using this error the local gradient of both outer and hidden layers is calculated. By using this local gradient weight update is done for both layers. This is done for all training sets. After finishing of an Epoch average error is calculated. Epochs keep on running until Eavg (average error)<10e-4 is achieved.
BUITEMS Quetta (2023). backprop.m (https://www.mathworks.com/matlabcentral/fileexchange/46841-backprop-m), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.