prepareNeuralNetwork überarbeitet und mit Änderung von Zeile 173 in neuralNetwor.c zu CreateMatrix funktionieren auch die Tests

This commit is contained in:
Mapama committed 2026-11-22 21:27:54 +01:00
1 parent 57708089a4
commit d9f7a2ab3f
2 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path)
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count) static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
{ {
Matrix matrix = {NULL, 0, 0}; Matrix matrix = createMatrix(0, 0);
if(count > 0 && images != NULL) if(count > 0 && images != NULL)
{ {
+1 -4
View File
@@ -14,7 +14,7 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
fwrite(fileHeader, sizeof(char), strlen(fileHeader), file); fwrite(fileHeader, sizeof(char), strlen(fileHeader), file);
if (nn.numberOfLayers > 0 && nn.layers != NULL) { if (nn.numberOfLayers > 0 && nn.layers != NULL) {
// Start Eingangsdimension der ersten Layer schreiben
int inputDimension = nn.layers[0].weights.cols; int inputDimension = nn.layers[0].weights.cols;
fwrite(&inputDimension, sizeof(int), 1, file); fwrite(&inputDimension, sizeof(int), 1, file);
@@ -22,15 +22,12 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
int outputDimension = nn.layers[i].weights.rows; int outputDimension = nn.layers[i].weights.rows;
fwrite(&outputDimension, sizeof(int), 1, file); fwrite(&outputDimension, sizeof(int), 1, file);
// Gewichte der Layer schreiben (OutputDim x InputDim)
int weightsCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols; int weightsCount = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightsCount, file); fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), weightsCount, file);
// Biases der Layer schreiben (OutputDim x 1)
int biasesCount = nn.layers[i].biases.rows * nn.layers[i].biases.cols; int biasesCount = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), biasesCount, file); fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), biasesCount, file);
} }
// Endsignal (0) schreiben, um die Einleseschleife in loadModel zu beenden
int endSignal = 0; int endSignal = 0;
fwrite(&endSignal, sizeof(int), 1, file); fwrite(&endSignal, sizeof(int), 1, file);
} }