Dark Blue with Orange

Download Report

Transcript Dark Blue with Orange

Artificial Neural Networks
for Pattern Recognition
Jack Breese
Computer Systems
Quarter 4, Pd. 7
What is a Neural Network?



Interconnected neurons
Weights
Output
Uses of Neural Networks

Pattern Recognition


Face Recognition
OCR
Neurons



Add up each weighted input
Use an activation function to determine output
Pass on output to next layer
Training Neural Networks


Large input set
Outputs are verified, weights adjusted along a
gradient based on these results.
For each neuron in the network:
For each connection to the neuron:
weight = random_value()
Until desired accuracy is reached:
For each example in the training data:
actual_out = run_network(example)
exp_out = calculate_expected(example)
error = exp_out – actual out
For each neuron in the network:
calculate_delta_weights(error)
adjust_weights(neuron)
Program Information




Neural Network Library written in C
Currently capable of initializing a two-layer
perceptron with working, weighted connections.
Capable of loading images and propagating data
through the network.
Can load images up to 500x500 pixels in size.
Data Structure
typedef struct _connection {
float weight;
struct _neuron * from;
} connection;
typedef struct _neuron { //TODO: Implement a neuron which
supports connections.
float d;
connection * cons;
}neuron;
neuron* mkneuron(int c) {
neuron* n = malloc(sizeof(neuron));
n->d = 0;
connection * a = malloc(c*sizeof(connection));;
n->cons = a;
return n;
}
New Progress




Load PGM Images
Create TrainingInfo structs
Begin Training
Perform Backpropagation
Training and Propagation Algos.
Calculating Neuron Values
For each neuron in the previous layer:
Sum += neuron_weight*neuron_value
neuron_value = activation_function(sum)
Training
For each neuron in the network:
For each connection to the neuron:
weight = random_value()
Until desired accuracy is reached:
For each example in the training data:
actual_out = run_network(example)
exp_out = calculate_expected(example)
error = exp_out – actual out
For each neuron in the network:
calculate_delta_weights(error)
adjust_weights(neuron)
New Data Structures


TrainInfo
pImg
Testing



Memory Usage was tested
Training was attempted
Values for known images and random weights
propagated through.
Problems Encountered

Initially thought memory usage was low.

Forgot to reset counter in nested for loops to 0.


Corrected problem, memory usage went up


That was dumb.
Decided to scale back network size/interconnectedness
Issues with String arrays in C

Prevented progress with training.
Conclusion



Works as a valid header file
Many methods
Useful for further exploration