|
|
Report
Code Description
Click to jump to a particular section of this page.
Code Reference
The original version, documented version and ported versions
of the code used can be found through the links below (or attached
sheets if hardcopy).
The file and data handling code used in this project is from the
Weka project
(www.cs.waikato.ac.nz/ml/weka/).
Weka is a collection of machine learning algorithms for solving
real-world data mining problems. It is written in Java and runs on
almost any platform. The algorithms can either be applied directly
to a dataset or called from your own Java code. Weka is also
well-suited for developing new machine learning schemes. Weka is
open source software issued under the GNU public license.
The only Weka code used in this project was that which
handles files and various data manipulation tasks. It was
also used to collect statistics on the performance of the
Back Propagation algorithm implemented.
The Back Propagation algorithm implementation provided by the
book was also used in this project.
Back to Top
Code Adaptation
The code from the book was ported to Java.
There were several reasons for this. The C code supplied
handled input that was in the form of an image, hence, containing
only numeric data to be handled.
The file parsing and data handling functionality
needed to handle the Census-Income data set was done in
Project 2
for Java.
This presented several options:
- Port file and data handling functionality to C
- Call native C functions from Java
- Port Neural Network - Back Propagation C code to Java
Porting the algorithm written in C to Java seemed to offer the
most educational experience.
Functions and sections used directly from backprop.c
double squash ( double x )
bpnn_ranodmize_weights ( double **w, int m, int n )
bpnn_zero_weights ( double **w, int m, int n )
bpnn_internal_create ( int n_in, int n_hidden, int n_out )
- Note: Just array declaration - allocation was used.
The ported code determines the number of input and output
nodes needed for the specified data set. This can be found
in the
BackPropagation.buildClassifier
method.
bpnn_create ( int n_in, int n_hidden, int n_out )
- See note above for
bpnn_internal_create
- Further more, the option to initialize weights with
zero values was not provided in the ported version.
bpnn_layerforward ( ... )
bpnn_ouput_error ( ... )
- Note: since this function is always called with the same
arguments which are available in the ported class
BackPropagation
, the argument list was removed.
- Note: The err value became the return value for the method
in the ported version
bpnn_hidden_error ( ... )
- Please see comments for
bpnn_output_error
bpnn_adjust_weights ( ... )
- Note:
eta and momentum
arguments were removed from argument list
and are contained and maintained by the BackPropagation
object.
These can be specified with command line options in the ported
version.
bpnn_feedforward ( BPNN *net )
- Note: argument removed since the method exist inside the object
equivalent of
BPNN
bpnn_train ( ... )
- Note: arguments were removed from ported version.
The sum of the error values became the return value of the
ported method. This was done since the calling function
always added these two values together. A more elegant solution
is possible with more time.
- Note: where
bpnn_train
explicitly called bpnn_layerforward
twice, the ported version calls the Feed Forward method.
This is equivalent, code wise, of how bpnn_train
uses Layer Forward.
Back to Top
|
|