Question
Implement perceptron neural networks to simulate the function for classifying an image with 2 x 2 pixels as shown below. Your input will be 16
Implement perceptron neural networks to simulate the function for classifying an image with 2 x 2 pixels as shown below. Your input will be 16 training examples. Do NOT simply have the user feed variables into a scanner to determine "bright" or "dark". C++, Java, or Python is acceptable. Include a description of how the program works.
Thumbs up if it's done right!
If the image contains 2, 3 or 4 white pixels, the output of perceptron is bright. If it contains 0 or 1 white pixels, it is classified as dark.
Some notes about the learning algorithm:
-Weights are set randomly initially
-For each training example E:
1) Calculate the observed output from the ANN, o(E)
2) If the target output t(E) is different to o(E), then tweak all the weights so that o(E) gets closer to t(E)
3) Tweaking is done by perceptron training rule (listed below). This routine is done for every input example E.
4) Dont necessarily stop when all examples used, repeat the cycle again (called an epoch) until the ANN produces the correct output for all the examples in the training set (or good enough)
Perceptron training rule:
When t(E) is different to o(E):
-Add on ?i to weight wi
-Where ?i = ?(t(E)-o(E))xi
-Do this for every weight in the network
? is the learning rate (between 0.0 and 1.0) and xi is input.
Interpretation:
-(t(E) o(E)) will either be + or
-So we can think of the addition of ?i as the movement of the weight in a direction
Which will improve the networks performance with respect to E
-Multiplication by xi
Moves it more if the input is bigger
Online Search Tool Example: Perceptron INPUT INPUT LAYER OUTPUT LAYE OUTPUT CATEGORY PIXEL 1- ?( x1 0.25 If S>-0.1 BRIGHT PIXEL 2 ??( x2 0.25 0.25 PIXEL 3- ? x3 otherwise -1 DARK 0.25 PIXEL 4 s-0.25%1 + 0.25%2 + 0.25%3 + 0.25%4 ? . Example calculation: x-1, x21, X3-1, x4-1 s-0.25%(-1) + 0.25*(1) + 0.25%(1) + 0.25%(-1)-0 -0.1, so the output from the ANN is +1 So the image is categorised as "bright" . 0 95 Online Search Tool Example: Perceptron INPUT INPUT LAYER OUTPUT LAYE OUTPUT CATEGORY PIXEL 1- ?( x1 0.25 If S>-0.1 BRIGHT PIXEL 2 ??( x2 0.25 0.25 PIXEL 3- ? x3 otherwise -1 DARK 0.25 PIXEL 4 s-0.25%1 + 0.25%2 + 0.25%3 + 0.25%4 ? . Example calculation: x-1, x21, X3-1, x4-1 s-0.25%(-1) + 0.25*(1) + 0.25%(1) + 0.25%(-1)-0 -0.1, so the output from the ANN is +1 So the image is categorised as "bright" . 0 95Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started