forked from freudenreichan/info2Praktikum-NeuronalesNetz
Implementierung der neuronalen Netzwerktests
This commit is contained in:
1 parent
cf8225b58d
commit
309e3144f9
1 file changed
+33
@@ -9,6 +9,39 @@
|
||||
static void prepareNeuralNetworkFile(const char *path, const NeuralNetwork nn)
|
||||
{
|
||||
// TODO
|
||||
FILE *file = fopen(path, "wb");
|
||||
if (file == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char *fileTag = "__info2_neural_network_file_format__";
|
||||
fwrite(fileTag, sizeof(char), strlen(fileTag), file);
|
||||
|
||||
if (nn.numberOfLayers > 0)
|
||||
{
|
||||
fwrite(&nn.layers[0].weights.cols, sizeof(int), 1, file);
|
||||
fwrite(&nn.layers[0].weights.rows, sizeof(int), 1, file);
|
||||
|
||||
for (unsigned int i = 0; i < nn.numberOfLayers; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
fwrite(&nn.layers[i].weights.rows, sizeof(int), 1, file);
|
||||
}
|
||||
|
||||
fwrite(nn.layers[i].weights.buffer, sizeof(MatrixType),
|
||||
nn.layers[i].weights.rows * nn.layers[i].weights.cols, file);
|
||||
|
||||
fwrite(nn.layers[i].biases.buffer, sizeof(MatrixType),
|
||||
nn.layers[i].biases.rows * nn.layers[i].biases.cols, file);
|
||||
}
|
||||
}
|
||||
|
||||
int endDimension = 0;
|
||||
fwrite(&endDimension, sizeof(int), 1, file);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void test_loadModelReturnsCorrectNumberOfLayers(void)
|
||||
|
||||
Reference in new issue
Block a user