diff --git a/Startcode/neuralNetwork.c b/Startcode/neuralNetwork.c index bd8f164..30e6e4f 100644 --- a/Startcode/neuralNetwork.c +++ b/Startcode/neuralNetwork.c @@ -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) { diff --git a/Startcode/neuralNetworkTests.c b/Startcode/neuralNetworkTests.c index 9b47149..5fa71f6 100644 --- a/Startcode/neuralNetworkTests.c +++ b/Startcode/neuralNetworkTests.c @@ -9,6 +9,8 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn) { // TODO + + //Datei zum binaeren schreiben oeffnen FILE *file = fopen(path, "wb"); if (file == NULL) @@ -16,20 +18,26 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn) return; } - const char *header = " __info2_neural_network_file_format__"; + //Header schreiben, loadModel prüft nach String + const char *header = "__info2_neural_network_file_format__"; fwrite(header, sizeof(char), strlen(header), file); + //Nur wenn mind. 1 layer da ist if (nn.numberOfLayers > 0) { + //Format entspricht anzahl der cols der Matrix des 1ten Layers int inputDimension = nn.layers[0].weights.cols; fwrite(&inputDimension, sizeof(int), 1, file); + //Layer nacheinander in Datei schreiben for (unsigned int i = 0; i < nn.numberOfLayers; i++) { Layer layer = nn.layers[i]; + //outputDimension entspricht Zeilenzahl seiner Matrix int outputDimension = layer.weights.rows; - + + //outputDim. speichern fwrite(&outputDimension, sizeof(int), 1, file); int weightCount = layer.weights.rows * layer.weights.cols; @@ -41,11 +49,13 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn) fwrite(layer.biases.buffer, sizeof(MatrixType), biasCount, file); } + //Abbruchkriterium für loadModel int endMarker = 0; fwrite(&endMarker, sizeof(int), 1, file); } + //Datei schließen fclose(file); }