generated from freudenreichan/info2Praktikum-NeuronalesNetz
Continued testing for functionality
This commit is contained in:
parent
bb96c8f78a
commit
0f28ee3f02
@ -10,8 +10,15 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
FILE* file = fopen(path, "wb");
|
FILE* file = fopen(path, "wb");
|
||||||
fwrite(path, sizeof(const char), 24, file);
|
if(file == NULL) {
|
||||||
fwrite(&(nn.nmberOfLayers), sizeof(unsigned int), 1, file);
|
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++) {
|
for(int i = 0; i < nn.numberOfLayers; i++) {
|
||||||
//write everything to do with weights
|
//write everything to do with weights
|
||||||
fwrite(&(nn.layers[i].weights.rows), sizeof(unsigned int), 1, file);
|
fwrite(&(nn.layers[i].weights.rows), sizeof(unsigned int), 1, file);
|
||||||
@ -23,6 +30,7 @@ static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
|||||||
fwrite(&(nn.layers[i].biases.cols), 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);
|
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)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user