complete version
This commit is contained in:
parent
a50550f3ea
commit
37d6d88ddf
@ -15,28 +15,30 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
FILE *file = fopen(path, "wb");
|
FILE *file = fopen(path, "wb");
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
|
// Dateikennzeichnung schreiben
|
||||||
const char *fileTag = "__info2_neural_network_file_format__";
|
const char *fileTag = "__info2_neural_network_file_format__";
|
||||||
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
||||||
|
|
||||||
|
// Alle Layer des Netzwerks in die Datei schreiben
|
||||||
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
|
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
|
||||||
{
|
{
|
||||||
unsigned int inputDim = nn.layers[i].weights.cols;
|
unsigned int inputDim = nn.layers[i].weights.cols;
|
||||||
unsigned int outputDim = nn.layers[i].weights.rows;
|
unsigned int outputDim = nn.layers[i].weights.rows;
|
||||||
|
|
||||||
// ghi dimensions
|
// Dimensionen des Layers schreiben
|
||||||
fwrite(&inputDim, sizeof(unsigned int), 1, file);
|
fwrite(&inputDim, sizeof(unsigned int), 1, file);
|
||||||
fwrite(&outputDim, sizeof(unsigned int), 1, file);
|
fwrite(&outputDim, sizeof(unsigned int), 1, file);
|
||||||
|
|
||||||
// ghi weights
|
// Gewichtsmatrix schreiben
|
||||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType),
|
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType),
|
||||||
nn.layers[i].weights.rows * nn.layers[i].weights.cols, file);
|
nn.layers[i].weights.rows * nn.layers[i].weights.cols, file);
|
||||||
|
|
||||||
// ghi biases
|
// Biasvektor schreiben
|
||||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType),
|
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType),
|
||||||
nn.layers[i].biases.rows * nn.layers[i].biases.cols, file);
|
nn.layers[i].biases.rows * nn.layers[i].biases.cols, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// đánh dấu hết layers
|
// Markierung für das Datei-Ende (keine weiteren Layer)
|
||||||
unsigned int zero = 0;
|
unsigned int zero = 0;
|
||||||
fwrite(&zero, sizeof(unsigned int), 1, file);
|
fwrite(&zero, sizeof(unsigned int), 1, file);
|
||||||
|
|
||||||
@ -45,9 +47,6 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// Test: Prüft, ob loadModel richtige Anzahl Layer lädt
|
// Test: Prüft, ob loadModel richtige Anzahl Layer lädt
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user