Homework 4
Introduction to Neural Networks
Due at the end of class Friday, March 14, 2014
10 Points
Submit this homework electronically to the eCompanion Dropbox
for Homework 4
Background
The human brain is an extremely complicated pattern recognizer and
is composed of billions of neurons. Provided that we can
mathematically model a neuron, it should be possible to to write a
program to model a neuron, and thus a pattern recognizer.
In 1958, Frank Rosenblatt proposed the a computational model of the
neuron that is both simple and elegant. This model can be
found at the following sites:
http://hagan.okstate.edu/nnd.html
http://www.pearsonhighered.com/assets/hip/us/hip_us_pearsonhighered/samplechapter/0131471392.pdf
For your reference the single perceptron model is provided in
ASCII art format below:
input_1 *
weight_1 -------+
|
input_2 * weight_2 -------+
| +-----+
+------------------+
input_3 * weight_3 -------+--->| Sum |---->| hardLim
function |----> Result
. .
.
| +-----+
+------------------+
input_n * weight_n
-------+ ^
|
bias
Note that the inputs are double precision values as are the weights
and biases.
The the weights are individually multiplied by the inputs and added
together with the bias as follows:
Sum = input_1*weight_1
+ input_2*weight_2 + . . . + input_n*weight_n + bias
Inputs, weights, and biases may be positive or negative.
The sum is provided to the hardLim function, which produces a result
that is either one or zero.
0, x < 0
hardLim(x) =
1, x >= 0
A single perceptron allows us to recognize the difference between
values that are linearly separable.
This means we can recognize classes that can be separated by a line,
plane, or hyperplane.
Hint: for problems 2 through 5, draw graphs of sample points and try
to figure out an equation for a line that separates those points.
All problems are worth 2 points. You may work with a partner
on this assignment, but you must submit your own solution.
1. Write a Java class that represents a perceptron. This class
must include as attributes, weights and a bias. It must
include a function that takes the same number of inputs as there are
weights in the perceptron and outputs a result indicating whether
the inputs belong to the class or not.
2. Create a perceptron that produces a result of one for values
greater than 2. Test this using a driver class.
3. Create a perceptron that takes 2 inputs and acts as an AND
gate. Test this using a driver class. Assume your inputs
will only be ones or zeroes.
4. Create a perceptron that acts 2 inputs and acts as an OR
gate. Test this using a driver class. Assume your inputs
will only be ones or zeroes.
5. Use two perceptrons to provide a result of 1 for values that are
greater than 5 or less than -3. Test this using a driver
class.