This commit is contained in:
Alexei Keller 2025-11-24 12:36:57 +01:00
parent fa26fbfb39
commit dd542429c9

View File

@ -8,24 +8,21 @@
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
{
// TODO : Fehlerbehandlung
// Öffne die Datei zum Schreiben im Binärmodus
FILE *file = fopen(path, "wb");
if (!file)
{
return;
}
if (!file) return;
// Schreibe den Datei-Tag
const char *tag = "info2_neural_network_file_format";
const char *tag = "__info2_neural_network_file_format__";
fwrite(tag, 1, strlen(tag), file);
// Überprüfe, ob es Layer gibt
if (nn.numberOfLayers == 0)
{
// Schreibe die Anzahl der Layer
if (nn.numberOfLayers == 0) {
fclose(file);
return;
}
// Schreibe die Eingabe- und Ausgabegrößen des Netzwerks
int input = nn.layers[0].weights.cols;
int output = nn.layers[0].weights.rows;
@ -54,6 +51,15 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
}
fclose(file);
// Debuging-Ausgabe
printf("prepareNeuralNetworkFile: Datei '%s' erstellt mit %u Layer(n)\n", path, nn.numberOfLayers);
for (unsigned int i = 0; i < nn.numberOfLayers; i++) {
Layer layer = nn.layers[i];
printf("Layer %u: weights (%u x %u), biases (%u x %u)\n",
i, layer.weights.rows, layer.weights.cols, layer.biases.rows, layer.biases.cols);
}
}
void test_loadModelReturnsCorrectNumberOfLayers(void)