Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7414865608 | ||
|
|
eb8db3856a | ||
|
|
aba8d54204 | ||
|
|
aa8ba9db4a | ||
|
|
b6ae8d17b1 |
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "imageInput.h"
|
#include "imageInput.h"
|
||||||
|
//test
|
||||||
#define BUFFER_SIZE 100
|
#define BUFFER_SIZE 100
|
||||||
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ NeuralNetwork loadModel(const char *path)
|
|||||||
|
|
||||||
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
static Matrix imageBatchToMatrixOfImageVectors(const GrayScaleImage images[], unsigned int count)
|
||||||
{
|
{
|
||||||
Matrix matrix = {NULL, 0, 0};
|
Matrix matrix = {0, 0, NULL};
|
||||||
|
|
||||||
if(count > 0 && images != NULL)
|
if(count > 0 && images != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,59 @@
|
|||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
//Datei zum binaeren schreiben oeffnen
|
||||||
|
FILE *file = fopen(path, "wb");
|
||||||
|
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Header schreiben, loadModel prüft nach String
|
||||||
|
const char *header = "__info2_neural_network_file_format__";
|
||||||
|
fwrite(header, sizeof(char), strlen(header), file);
|
||||||
|
|
||||||
|
//Prüfen ob Layer existieren
|
||||||
|
if (nn.numberOfLayers > 0)
|
||||||
|
{
|
||||||
|
//Format entspricht anzahl der cols der Matrix des 1ten Layers
|
||||||
|
int inputDimension = nn.layers[0].weights.cols;
|
||||||
|
fwrite(&inputDimension, sizeof(int), 1, file);
|
||||||
|
|
||||||
|
//Layer nacheinander in Datei schreiben
|
||||||
|
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
|
||||||
|
{
|
||||||
|
Layer layer = nn.layers[i];
|
||||||
|
|
||||||
|
//outputDimension entspricht Zeilenzahl seiner Matrix
|
||||||
|
int outputDimension = layer.weights.rows;
|
||||||
|
|
||||||
|
//outputDim. speichern
|
||||||
|
fwrite(&outputDimension, sizeof(int), 1, file);
|
||||||
|
|
||||||
|
//weight werte berechnen
|
||||||
|
int weightCount = layer.weights.rows * layer.weights.cols;
|
||||||
|
|
||||||
|
//Matrix speichern
|
||||||
|
fwrite(layer.weights.buffer, sizeof(MatrixType), weightCount, file);
|
||||||
|
|
||||||
|
//bias berechnen
|
||||||
|
int biasCount = layer.biases.rows * layer.biases.cols;
|
||||||
|
|
||||||
|
//bias speichern
|
||||||
|
fwrite(layer.biases.buffer, sizeof(MatrixType), biasCount, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Abbruchkriterium für loadModel
|
||||||
|
int ende= 0;
|
||||||
|
|
||||||
|
fwrite(&ende, sizeof(int), 1, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Datei schließen
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
Reference in new issue
Block a user