generated from freudenreichan/info2Praktikum-NeuronalesNetz
Compare commits
3 Commits
0a8349d722
...
0f28ee3f02
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f28ee3f02 | |||
| bb96c8f78a | |||
| cfb3848fe2 |
@ -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}; // TODO changed this line to fit our functionality
|
||||
|
||||
if(count > 0 && images != NULL)
|
||||
{
|
||||
|
||||
@ -9,6 +9,28 @@
|
||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
{
|
||||
// TODO
|
||||
FILE* file = fopen(path, "wb");
|
||||
if(file == NULL) {
|
||||
printf("Failed to open file");
|
||||
return;
|
||||
}
|
||||
|
||||
const char* header = "__info2_neural_network_file_format__";
|
||||
fwrite(header, sizeof(const char), strlen(header), file);
|
||||
fwrite(&(nn.numberOfLayers), sizeof(unsigned int), 1, file);
|
||||
fwrite(&(nn.numberOfLayers), sizeof(unsigned int), 1, file);
|
||||
for(int i = 0; i < nn.numberOfLayers; i++) {
|
||||
//write everything to do with weights
|
||||
fwrite(&(nn.layers[i].weights.rows), sizeof(unsigned int), 1, file);
|
||||
fwrite(&(nn.layers[i].weights.cols), sizeof(unsigned int), 1, file);
|
||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), nn.layers[i].weights.rows * nn.layers[i].weights.cols, file);
|
||||
|
||||
//write everything to do with biases
|
||||
fwrite(&(nn.layers[i].biases.rows), sizeof(unsigned int), 1, file);
|
||||
fwrite(&(nn.layers[i].biases.cols), sizeof(unsigned int), 1, file);
|
||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), nn.layers[i].biases.rows * nn.layers[i].biases.cols, file);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user