25 v.
val[i] = (i==targetIndex) ? 1 : 0;
46 l->
cell[o].
weight[i]=rand()/(double)(RAND_MAX);
124 double err = target - c->
output;
void updateCellWeights(Cell *c, double err)
Updates a cell's weights based on given error and LEARNING_RATE.
Cell cell[NUMBER_OF_OUTPUT_CELLS]
Data structure containing defined number of integer values (the output vector contains values for 0-9...
Vector getTargetOutput(int targetIndex)
Returns an output vector with targetIndex set to 1, all others to 0.
void setCellInput(Cell *c, MNIST_Image *img)
Sets a cell's input according to the pixels of a given MNIST image.
#define LEARNING_RATE
Incremental increase for changing connection weights.
void testCell(Cell *c, MNIST_Image *img, int target)
Performs the testing of the trained network.
double getCellError(Cell *c, int target)
Returns the difference between a target value and the cell's ouput.
void calcCellOutput(Cell *c)
Calculates a cell's output by suming all input-weight-products.
#define NUMBER_OF_OUTPUT_CELLS
use 10 output cells to model 10 digits (0-9)
Machine learning functionality for a 1-layer neural network.
Core unit of the neural network (neuron and synapses)
The single (output) layer of this network (a layer is number cells)
double weight[NUMBER_OF_INPUT_CELLS]
#define NUMBER_OF_INPUT_CELLS
use 28*28 input cells (= number of pixels per MNIST image)
int val[NUMBER_OF_OUTPUT_CELLS]
void trainCell(Cell *c, MNIST_Image *img, int target)
Performs the training algorithm.
void initLayer(Layer *l)
Initialize layer by setting all weights to random values [0-1].
double input[NUMBER_OF_INPUT_CELLS]
Utitlies for handling the MNIST files.
int getLayerPrediction(Layer *l)
Returns the index of the cell with the hightest output.
Data block defining a MNIST image.