MNIST-1LNN
1.0
A simple 1-layer neural network to recognize handwritten single digit numbers from the MNIST image files.
|
Machine learning functionality for a 1-layer neural network. More...
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "mnist-utils.h"
#include "1lnn.h"
Go to the source code of this file.
Functions | |
Vector | getTargetOutput (int targetIndex) |
Returns an output vector with targetIndex set to 1, all others to 0. More... | |
void | initLayer (Layer *l) |
Initialize layer by setting all weights to random values [0-1]. More... | |
int | getLayerPrediction (Layer *l) |
Returns the index of the cell with the hightest output. More... | |
void | setCellInput (Cell *c, MNIST_Image *img) |
Sets a cell's input according to the pixels of a given MNIST image. More... | |
void | calcCellOutput (Cell *c) |
Calculates a cell's output by suming all input-weight-products. More... | |
double | getCellError (Cell *c, int target) |
Returns the difference between a target value and the cell's ouput. More... | |
void | updateCellWeights (Cell *c, double err) |
Updates a cell's weights based on given error and LEARNING_RATE. More... | |
void | trainCell (Cell *c, MNIST_Image *img, int target) |
Performs the training algorithm. More... | |
void | testCell (Cell *c, MNIST_Image *img, int target) |
Performs the testing of the trained network. More... | |
Machine learning functionality for a 1-layer neural network.
Definition in file 1lnn.c.
void calcCellOutput | ( | Cell * | c | ) |
double getCellError | ( | Cell * | c, |
int | target | ||
) |
int getLayerPrediction | ( | Layer * | l | ) |
Vector getTargetOutput | ( | int | targetIndex | ) |
void initLayer | ( | Layer * | l | ) |
Initialize layer by setting all weights to random values [0-1].
Initialize layer by setting all weights to random values [0-1]
void setCellInput | ( | Cell * | c, |
MNIST_Image * | img | ||
) |
Sets a cell's input according to the pixels of a given MNIST image.
Creates an input vector of length NUMBER_OF_INPUT_CELLS of a given MNIST image, setting input vector cells to [0,1] based on the pixels of the image. Scalar pixel intensity [=grey-scale] is ignored, only 0 or 1 [=black-white].
void testCell | ( | Cell * | c, |
MNIST_Image * | img, | ||
int | target | ||
) |
void trainCell | ( | Cell * | c, |
MNIST_Image * | img, | ||
int | target | ||
) |