Testen moeglich, 6 Failures

This commit is contained in:
silvana884 2025-11-24 21:34:02 +01:00
parent 4a6e7a904a
commit 58f9fd8115
5 changed files with 39 additions and 10 deletions

2
.idea/workspace.xml generated
View File

@ -20,7 +20,7 @@
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="93ee913b-6a02-4be9-9f16-9e5959cb8dc8" name="Changes" comment="" />
<list default="true" id="df1feb62-39b8-4aeb-a745-19618bf4ab77" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@ -6,6 +6,11 @@
typedef float MatrixType;
// TODO Matrixtyp definieren
typedef struct{
unsigned int rows;
unsigned int cols;
MatrixType *buffer; //Data wird in einem eindimensionalen Array gespeichert (Spalten und Reihen liegen ja im Speicher hintereinannder)
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);
@ -13,7 +18,10 @@ void clearMatrix(Matrix *matrix);
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
Matrix add(const Matrix matrix1, const Matrix matrix2);
Matrix broadcasting(const Matrix matrix1, const Matrix matrix2);
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
int rows(const Matrix matrix);
int cols(const Matrix matrix);
#endif

View File

@ -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)
{

View File

@ -1,6 +1,8 @@
#ifndef NEURALNETWORK_H
#define NEURALNETWORK_H
#define FILE_HEADER_STRING "__info2_neural_network_file_format__"
#include "imageInput.h"
#include "matrix.h"

View File

@ -4,28 +4,47 @@
#include <math.h>
#include "unity.h"
#include "neuralNetwork.h"
#include "neuralNetwork.c"
//Dateischichten sind in neuralNetwork.h definiert
// Dateiname: __info2_neural_network_file_format__
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
{
// Datei oeffnen
FILE *file = fopen(path, "wb");
if (!file) return;
// Header schreiben
fwrite(FILE_HEADER_STRING, 1, strlen(FILE_HEADER_STRING), file);
if (file == NULL)
return 1;
// Anzahl Layer schreiben
uint32_t nLayers = nn.numberOfLayers;
fwrite(&nLayers, sizeof(uint32_t), 1, file);
// header schreiben
fwrite(FILE_HEADER_STRING, sizeof(char), strlen(FILE_HEADER_STRING), file);
for (uint32_t i = 0; i < nLayers; i++) {
Layer layer = nn.layers[i];
// Weights-Dimensionen
uint32_t rW = layer.weights.rows;
uint32_t cW = layer.weights.cols;
fwrite(&rW, sizeof(uint32_t), 1, file);
fwrite(&cW, sizeof(uint32_t), 1, file);
// Weights-Werte
fwrite(layer.weights.buffer, sizeof(MatrixType), rW * cW, file);
// Bias-Dimensionen
uint32_t rB = layer.biases.rows;
uint32_t cB = layer.biases.cols;
fwrite(&rB, sizeof(uint32_t), 1, file);
fwrite(&cB, sizeof(uint32_t), 1, file);
// Bias-Werte
fwrite(layer.biases.buffer, sizeof(MatrixType), rB * cB, file);
}
// Datei wieder schließen!
fclose(file);
}
void test_loadModelReturnsCorrectNumberOfLayers(void)
{
const char *path = "some__nn_test_file.info2";