forked from freudenreichan/info2Praktikum-NeuronalesNetz
prepareNeuralNetwork initial implementation
This commit is contained in:
1 parent
7c5a0c012f
commit
833a4c3c79
2 files changed
+19
-3
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user