Test 4
This commit is contained in:
parent
fa26fbfb39
commit
dd542429c9
@ -8,24 +8,21 @@
|
||||
|
||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
{
|
||||
FILE *file = fopen(path, "wb");
|
||||
if (!file)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TODO : Fehlerbehandlung
|
||||
// Öffne die Datei zum Schreiben im Binärmodus
|
||||
FILE *file = fopen(path, "wb");
|
||||
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;
|
||||
@ -40,10 +37,10 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
int out = layer->weights.rows;
|
||||
int in = layer->weights.cols;
|
||||
|
||||
|
||||
|
||||
fwrite(layer->weights.buffer, sizeof(MatrixType), out * in, file);
|
||||
|
||||
|
||||
|
||||
fwrite(layer->biases.buffer, sizeof(MatrixType), out * 1, file);
|
||||
|
||||
if (i + 1 < nn.numberOfLayers)
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user