Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5909e80b88 | ||
|
|
9af49e1ec2 | ||
|
|
6a2767fa71 | ||
|
|
dd542429c9 |
+11
-11
@@ -8,24 +8,22 @@
|
||||
|
||||
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
|
||||
// Überprüfe, ob Layer vorhanden sind
|
||||
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 +38,9 @@ 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,9 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
Reference in New Issue
Block a user