diff --git a/neuralNetworkTests.c b/neuralNetworkTests.c index 21ab370..6cc4303 100644 --- a/neuralNetworkTests.c +++ b/neuralNetworkTests.c @@ -8,7 +8,32 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn) { - // TODO + FILE *file = fopen(path, "wb"); + + if(file != NULL){ + const char *fileTag = "__info2_neural_network_file_format__"; + fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file); + + int inputDimension = nn.layers[0].weights.cols; + fwrite(&inputDimension,sizeof(inputDimension), 1, file); + + for (int i = 0; i < nn.numberOfLayers; i++) + { + unsigned int outputDimension = nn.layers[i].weights.rows; + fwrite(&outputDimension, sizeof(outputDimension), 1, file); + + unsigned int numWeights = nn.layers[i].weights.rows * nn.layers[i].weights.cols; + fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), numWeights, file); + + unsigned int numBiases = nn.layers[i].biases.rows * nn.layers[i].biases.cols; + fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), 1, file); + } + + unsigned int outputDimension = 0; + fwrite(&outputDimension, sizeof(outputDimension), 1, file); + + fclose(file); + } } void test_loadModelReturnsCorrectNumberOfLayers(void) diff --git a/runImageInputTests b/runImageInputTests index 6ee9ae7..2b262f4 100755 Binary files a/runImageInputTests and b/runImageInputTests differ diff --git a/runImageInputTests.dSYM/Contents/Resources/DWARF/runImageInputTests b/runImageInputTests.dSYM/Contents/Resources/DWARF/runImageInputTests index 88955c8..5bb7947 100644 Binary files a/runImageInputTests.dSYM/Contents/Resources/DWARF/runImageInputTests and b/runImageInputTests.dSYM/Contents/Resources/DWARF/runImageInputTests differ diff --git a/runMatrixTests b/runMatrixTests index 8f166d2..735df69 100755 Binary files a/runMatrixTests and b/runMatrixTests differ diff --git a/runMatrixTests.dSYM/Contents/Resources/DWARF/runMatrixTests b/runMatrixTests.dSYM/Contents/Resources/DWARF/runMatrixTests index d37b96a..1ecd83f 100644 Binary files a/runMatrixTests.dSYM/Contents/Resources/DWARF/runMatrixTests and b/runMatrixTests.dSYM/Contents/Resources/DWARF/runMatrixTests differ