generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
No commits in common. "TobiasV2" and "main" have entirely different histories.
13
matrix.c
13
matrix.c
@ -131,17 +131,4 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
void writeMatrix(Matrix matrix, FILE *file)//Added for neuralNetworkTests
|
||||
{
|
||||
//fprintf(file, "%d%d", matrix.rows, matrix.cols);
|
||||
for(int i = 0; i < matrix.rows; i++)
|
||||
{
|
||||
for(int j = 0; j < matrix.cols; j++)
|
||||
{
|
||||
putw(*(matrix.buffer + (j+i)*sizeof(MatrixType)), file);
|
||||
//fprintf(file, "%f", *(matrix.buffer + (j+i)*sizeof(MatrixType)));
|
||||
printf("%f", *(matrix.buffer + (j+i)*sizeof(MatrixType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
1
matrix.h
1
matrix.h
@ -21,7 +21,6 @@ void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned
|
||||
MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int colIdx);
|
||||
Matrix add(const Matrix matrix1, const Matrix matrix2);
|
||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
||||
void writeMatrix(Matrix matrix, FILE *file);//Added for neuralNetworkTests
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -4,23 +4,11 @@
|
||||
#include <math.h>
|
||||
#include "unity.h"
|
||||
#include "neuralNetwork.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
{
|
||||
FILE *testDatei = fopen(path, "w");
|
||||
fprintf(testDatei, "__info2_neural_network_file_format__");
|
||||
fprintf(testDatei, "%d%d", nn.layers->weights.rows, nn.layers->weights.cols);
|
||||
// fprintf(testDatei, (char*) nn.numberOfLayers);
|
||||
for(int i = 0; i < nn.numberOfLayers; i++)
|
||||
{
|
||||
//fprintf(testDatei, "\n");
|
||||
//putw((nn.layers + sizeof(Layer) * i), testDatei);
|
||||
writeMatrix(nn.layers[i].weights, testDatei);
|
||||
writeMatrix(nn.layers[i].biases, testDatei);
|
||||
}
|
||||
fclose(testDatei);
|
||||
// TODO
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
@ -43,7 +31,7 @@ void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
netUnderTest = loadModel(path);
|
||||
remove(path);
|
||||
printf("\n%d\n%d\n", netUnderTest.numberOfLayers, expectedNet.numberOfLayers);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(expectedNet.numberOfLayers, netUnderTest.numberOfLayers);
|
||||
clearModel(&netUnderTest);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user