Compare commits
2 Commits
fa26fbfb39
...
6a2767fa71
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a2767fa71 | |||
| dd542429c9 |
@ -8,24 +8,21 @@
|
|||||||
|
|
||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
|
// TODO : Fehlerbehandlung
|
||||||
|
// Öffne die Datei zum Schreiben im Binärmodus
|
||||||
FILE *file = fopen(path, "wb");
|
FILE *file = fopen(path, "wb");
|
||||||
if (!file)
|
if (!file) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Schreibe den Datei-Tag
|
// 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);
|
fwrite(tag, 1, strlen(tag), file);
|
||||||
|
|
||||||
// Überprüfe, ob es Layer gibt
|
// Schreibe die Anzahl der Layer
|
||||||
if (nn.numberOfLayers == 0)
|
if (nn.numberOfLayers == 0) {
|
||||||
{
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Schreibe die Eingabe- und Ausgabegrößen des Netzwerks
|
// Schreibe die Eingabe- und Ausgabegrößen des Netzwerks
|
||||||
int input = nn.layers[0].weights.cols;
|
int input = nn.layers[0].weights.cols;
|
||||||
int output = nn.layers[0].weights.rows;
|
int output = nn.layers[0].weights.rows;
|
||||||
@ -40,7 +37,6 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
int out = layer->weights.rows;
|
int out = layer->weights.rows;
|
||||||
int in = layer->weights.cols;
|
int in = layer->weights.cols;
|
||||||
|
|
||||||
|
|
||||||
fwrite(layer->weights.buffer, sizeof(MatrixType), out * in, file);
|
fwrite(layer->weights.buffer, sizeof(MatrixType), out * in, file);
|
||||||
|
|
||||||
|
|
||||||
@ -54,6 +50,15 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
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)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user