diff --git a/Startcode/neuralNetwork.c b/Startcode/neuralNetwork.c index bd8f164..b0b63cc 100644 --- a/Startcode/neuralNetwork.c +++ b/Startcode/neuralNetwork.c @@ -67,14 +67,14 @@ static unsigned int readDimension(FILE *file) if(fread(&dimension, sizeof(int), 1, file) != 1) dimension = 0; - + return dimension; } static Matrix readMatrix(FILE *file, unsigned int rows, unsigned int cols) { Matrix matrix = createMatrix(rows, cols); - + if(matrix.buffer != NULL) { if(fread(matrix.buffer, sizeof(MatrixType), rows*cols, file) != rows*cols) @@ -128,7 +128,7 @@ NeuralNetwork loadModel(const char *path) { if(checkFileHeader(file)) { - unsigned int inputDimension = readDimension(file); + unsigned int inputDimension = readDimension(file); unsigned int outputDimension = readDimension(file); while(inputDimension > 0 && outputDimension > 0) @@ -142,7 +142,7 @@ NeuralNetwork loadModel(const char *path) clearModel(&model); break; } - + layerBuffer = (Layer *)realloc(model.layers, (model.numberOfLayers + 1) * sizeof(Layer)); if(layerBuffer != NULL) @@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path) static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count) { - Matrix matrix = {NULL, 0, 0}; + Matrix matrix = {0, 0, NULL}; if(count > 0 && images != NULL) { @@ -201,7 +201,7 @@ static Matrix forward(const NeuralNetwork model, Matrix inputBatch) { Matrix biasResult; Matrix weightResult; - + weightResult = multiply(model.layers[i].weights, result); clearMatrix(&result); biasResult = add(model.layers[i].biases, weightResult); @@ -248,9 +248,9 @@ unsigned char *predict(const NeuralNetwork model, const GrayScaleImage images[], Matrix outputBatch = forward(model, inputBatch); unsigned char *result = argmax(outputBatch); - + clearMatrix(&outputBatch); - + return result; } @@ -265,4 +265,4 @@ void clearModel(NeuralNetwork *model) model->layers = NULL; model->numberOfLayers = 0; } -} \ No newline at end of file +} diff --git a/Startcode/runNeuralNetworkTests b/Startcode/runNeuralNetworkTests new file mode 100755 index 0000000..15b6417 Binary files /dev/null and b/Startcode/runNeuralNetworkTests differ