forked from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
447e77a7bf | ||
|
|
a6749f07d1 |
+60
-3
@@ -1,4 +1,61 @@
|
|||||||
mnist
|
# ---> C
|
||||||
runTests
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
Startcode/mnist
|
||||||
|
Startcode/runTests
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
||||||
|
|
||||||
|
# IDE folders
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@@ -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 = {0, 0, NULL};
|
Matrix matrix = {NULL, 0, 0};
|
||||||
|
|
||||||
if(count > 0 && images != NULL)
|
if(count > 0 && images != NULL)
|
||||||
{
|
{
|
||||||
@@ -5,46 +5,10 @@
|
|||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "neuralNetwork.h"
|
#include "neuralNetwork.h"
|
||||||
|
|
||||||
static void writeLayer(FILE *file, const Matrix weights, const Matrix biases, unsigned int inputDim)
|
|
||||||
{
|
|
||||||
unsigned int outputDim = (unsigned int)weights.rows;
|
|
||||||
fwrite(&outputDim, sizeof(unsigned int), 1, file);
|
|
||||||
if (weights.buffer != NULL)
|
|
||||||
fwrite(weights.buffer, sizeof(MatrixType), outputDim * inputDim, file);
|
|
||||||
|
|
||||||
if (biases.buffer != NULL)
|
|
||||||
fwrite(biases.buffer, sizeof(MatrixType), outputDim, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
FILE *file = fopen(path, "wb");
|
// TODO
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
const char tag[] = "__info2_neural_network_file_format__";
|
|
||||||
fwrite(tag, sizeof(char), strlen(tag), file);
|
|
||||||
|
|
||||||
if (nn.numberOfLayers == 0)
|
|
||||||
{
|
|
||||||
unsigned int zero = 0;
|
|
||||||
fwrite(&zero, sizeof(unsigned int), 1, file);
|
|
||||||
fclose(file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int inputDim = (unsigned int)nn.layers[0].weights.cols;
|
|
||||||
fwrite(&inputDim, sizeof(unsigned int), 1, file);
|
|
||||||
|
|
||||||
for (int i = 0; i < nn.numberOfLayers; i++)
|
|
||||||
{
|
|
||||||
writeLayer(file, nn.layers[i].weights, nn.layers[i].biases, inputDim);
|
|
||||||
inputDim = (unsigned int)nn.layers[i].weights.rows;
|
|
||||||
}
|
|
||||||
unsigned int zero = 0;
|
|
||||||
fwrite(&zero, sizeof(unsigned int), 1, file);
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
Reference in New Issue
Block a user