forked from freudenreichan/info2Praktikum-NeuronalesNetz
Merge remote-tracking branch 'origin/neuralNetworkTests' into simon
This commit is contained in:
commit
01a13090a5
@ -6,9 +6,30 @@
|
||||
#include "neuralNetwork.h"
|
||||
|
||||
|
||||
static void erzeugeMatrix(FILE *file, const Matrix *m)
|
||||
{
|
||||
fwrite(&m->rows, sizeof(int), 1, file);
|
||||
fwrite(&m->cols, sizeof(int), 1, file);
|
||||
fwrite(m->buffer, sizeof(MatrixType), m->rows * m->cols, file);
|
||||
}
|
||||
|
||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
{
|
||||
// TODO
|
||||
FILE *file = fopen(path, "wb");
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
const char *header = "__info2_neural_network_file_format__";
|
||||
fwrite(header, sizeof(char), strlen(header), file);
|
||||
fwrite(&nn.numberOfLayers, sizeof(int), 1, file);
|
||||
|
||||
for (int i = 0; i < nn.numberOfLayers; i++)
|
||||
{
|
||||
erzeugeMatrix(file, &nn.layers[i].weights);
|
||||
erzeugeMatrix(file, &nn.layers[i].biases);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user