merged initial model prep function

This commit is contained in:
reeceal105988 committed 2026-10-29 15:22:31 +01:00
commit d2065df23a
1 file changed
+18 -2
+18 -2
View File
@@ -4,11 +4,27 @@
#include <math.h>
#include "unity.h"
#include "neuralNetwork.h"
#define FILE_HEADER_STRING "__info2_neural_network_file_format__"
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
{
// TODO
FILE *fd = fopen(path, "wb");
if (fd == NULL)
return;
fwrite(FILE_HEADER_STRING, sizeof(FILE_HEADER_STRING) - 1, 1, fd);
// fwrite(&nn, sizeof(nn), 1, fd);
fwrite(&(nn.layers[0].weights.cols), sizeof(nn.layers[0].weights.cols), 1, fd);
for (int i = 0; i < nn.numberOfLayers; ++i)
{
fwrite(&(nn.layers[i].weights.rows), sizeof(nn.layers[i].weights.rows), 1, fd);
fwrite(&(nn.layers[i].weights.buffer), sizeof(MatrixType) * nn.layers[i].weights.rows * nn.layers[i].weights.cols, 1, fd);
fwrite(&(nn.layers[i].biases.buffer), sizeof(MatrixType) * nn.layers[i].biases.rows, 1, fd);
}
const float zeroooooo = 0.0F;
fwrite(&zeroooooo, sizeof(MatrixType), 1, fd);
fclose(fd);
}
void test_loadModelReturnsCorrectNumberOfLayers(void)