Merge remote-tracking branch 'origin/neuralNetworkTests' into simon

This commit is contained in:
Simon Wiesend 2025-11-23 15:53:22 +01:00
commit 01a13090a5
Signed by: wiesendsi102436
GPG Key ID: C18A833054142CF0

View File

@ -6,9 +6,30 @@
#include "neuralNetwork.h"
static void erzeugeMatrix(FILE *file, const Matrix *m)
{
fwrite(&m->rows, sizeof(int), 1, file);
fwrite(&m->cols, sizeof(int), 1, file);
fwrite(m->buffer, sizeof(MatrixType), m->rows * m->cols, file);
}
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
{
// TODO
FILE *file = fopen(path, "wb");
if (!file)
return;
const char *header = "__info2_neural_network_file_format__";
fwrite(header, sizeof(char), strlen(header), file);
fwrite(&nn.numberOfLayers, sizeof(int), 1, file);
for (int i = 0; i < nn.numberOfLayers; i++)
{
erzeugeMatrix(file, &nn.layers[i].weights);
erzeugeMatrix(file, &nn.layers[i].biases);
}
fclose(file);
}
void test_loadModelReturnsCorrectNumberOfLayers(void)