Änderung an neuralesNetwork.c vorgenommen, weil es die Funktion aus

matrix.c falsch benutzt hat
This commit is contained in:
KohlerMaxi committed 2026-11-09 14:45:19 +01:00
1 parent 8c8637bc48
commit 3af1970eb7
2 files changed
+9 -9

No files matched your search

+9 -9
View File
@@ -67,14 +67,14 @@ static unsigned int readDimension(FILE *file)
if(fread(&dimension, sizeof(int), 1, file) != 1)
dimension = 0;
return dimension;
}
static Matrix readMatrix(FILE *file, unsigned int rows, unsigned int cols)
{
Matrix matrix = createMatrix(rows, cols);
if(matrix.buffer != NULL)
{
if(fread(matrix.buffer, sizeof(MatrixType), rows*cols, file) != rows*cols)
@@ -128,7 +128,7 @@ NeuralNetwork loadModel(const char *path)
{
if(checkFileHeader(file))
{
unsigned int inputDimension = readDimension(file);
unsigned int inputDimension = readDimension(file);
unsigned int outputDimension = readDimension(file);
while(inputDimension > 0 && outputDimension > 0)
@@ -142,7 +142,7 @@ NeuralNetwork loadModel(const char *path)
clearModel(&model);
break;
}
layerBuffer = (Layer *)realloc(model.layers, (model.numberOfLayers + 1) * sizeof(Layer));
if(layerBuffer != NULL)
@@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path)
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
{
Matrix matrix = {NULL, 0, 0};
Matrix matrix = {0, 0, NULL};
if(count > 0 && images != NULL)
{
@@ -201,7 +201,7 @@ static Matrix forward(const NeuralNetwork model, Matrix inputBatch)
{
Matrix biasResult;
Matrix weightResult;
weightResult = multiply(model.layers[i].weights, result);
clearMatrix(&result);
biasResult = add(model.layers[i].biases, weightResult);
@@ -248,9 +248,9 @@ unsigned char *predict(const NeuralNetwork model, const GrayScaleImage images[],
Matrix outputBatch = forward(model, inputBatch);
unsigned char *result = argmax(outputBatch);
clearMatrix(&outputBatch);
return result;
}
@@ -265,4 +265,4 @@ void clearModel(NeuralNetwork *model)
model->layers = NULL;
model->numberOfLayers = 0;
}
}
}