generated from freudenreichan/info2Praktikum-NeuronalesNetz
Added a prepareNeuralNetwork funktion, that compiles but fails 6/8 tests
This commit is contained in:
parent
0a8349d722
commit
06782431a4
10
matrix.c
10
matrix.c
@ -131,4 +131,14 @@ Matrix multiply(const Matrix matrix1, const Matrix matrix2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
void writeMatrix(Matrix matrix, FILE *file)//Added for neuralNetworkTests
|
||||||
|
{
|
||||||
|
for(int i = 0; i < matrix.rows; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < matrix.cols; j++)
|
||||||
|
{
|
||||||
|
fprintf(file, (char*)(matrix.buffer + (j+i)*sizeof(MatrixType)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
1
matrix.h
1
matrix.h
@ -21,6 +21,7 @@ void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned
|
|||||||
MatrixType getMatrixAt(const 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 add(const Matrix matrix1, const Matrix matrix2);
|
||||||
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
Matrix multiply(const Matrix matrix1, const Matrix matrix2);
|
||||||
|
void writeMatrix(Matrix matrix, FILE *file);//Added for neuralNetworkTests
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -4,11 +4,20 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "neuralNetwork.h"
|
#include "neuralNetwork.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
// TODO
|
FILE *testDatei = fopen(path, "w");
|
||||||
|
fprintf(testDatei, "__info2_neural_network_file_format__");
|
||||||
|
for(int i = 0; i < nn.numberOfLayers; i++)
|
||||||
|
{
|
||||||
|
fprintf(testDatei, "\n");
|
||||||
|
writeMatrix(nn.layers[i].weights, testDatei);
|
||||||
|
writeMatrix(nn.layers[i].biases, testDatei);
|
||||||
|
}
|
||||||
|
fclose(testDatei);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user