forked from freudenreichan/info2Praktikum-NeuronalesNetz
bearbeitet
This commit is contained in:
1 parent
ff3ba69099
commit
33d9ac7833
1 file changed
+29
-1
@@ -8,7 +8,35 @@
|
|||||||
|
|
||||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
|
FILE *file = fopen(path, "wb");
|
||||||
|
|
||||||
|
if (file != NULL){
|
||||||
|
|
||||||
|
const char *fileTag = "__info2_neural_network_file_format__";
|
||||||
|
|
||||||
|
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
||||||
|
fwrite(&nn.numberOfLayers, sizeof(nn.numberOfLayers), 1, file);
|
||||||
|
|
||||||
|
for(int i = 0; i < nn.numberOfLayers; i++){
|
||||||
|
fwrite(&nn.layers[i].weights.rows, sizeof(nn.layers[i].weights.rows), 1, file);
|
||||||
|
fwrite(&nn.layers[i].weights.cols, sizeof(nn.layers[i].weights.cols), 1, file);
|
||||||
|
|
||||||
|
unsigned int nWeights = nn.layers[i].weights.rows * nn.layers[i].weights.cols;
|
||||||
|
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType), nWeights, file);
|
||||||
|
|
||||||
|
fwrite(&nn.layers[i].biases.rows, sizeof(nn.layers[i].biases.rows), 1, file);
|
||||||
|
fwrite(&nn.layers[i].biases.cols, sizeof(nn.layers[i].biases.cols), 1, file);
|
||||||
|
|
||||||
|
unsigned int nBiases = nn.layers[i].biases.rows * nn.layers[i].biases.cols;
|
||||||
|
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType), nBiases, file);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||||
|
|||||||
Reference in new issue
Block a user